Cloudfront cache issues when content updates to new version

|
| By Webner

Problem: Cloudfront caches most of the objects and it becomes a problem when content updates to a new version of the origin server. CloudFront doesn’t retrieve the latest version of objects instantly from the origin server, it generally takes 24 – 48 hrs to recache the same object.

Solution: Below are some simple and efficient ways to completely clear up the CloudFront cache from root location of the bucket, I am going to explain them one by one.

>>First way, using AWS cli:

You need to set AWS credentials first in command line using below command.

$ aws configure (use this command if you have not set any aws credentials earlier)
or
$ aws configure –profile profile_name (use this command to set multiple aws credentials for different purposes)

Below is a Sample:

<b>AWS Access Key ID [None]: AKIAI44NAVNWBESAMPLE
AWS Secret Access Key [None]: ke7NtGbCleBF3aVN8nwbESAMPLEKEY
Default region name [None]: us-east-1
Default output format [None]: text</b>

Now, execute the below command to clear the cache from cloudfront edge locations:

$ aws cloudfront create-invalidation –distribution-id= –paths / –profile=

>>Second way, using AWS console:

Step.1 open CloudFront in AWS console:

Step.2 Select the Distribution as shown below and Click Distribution settings:

Step.3 Now, click Invalidation option from sub-menu:

Step.4 Run the below command to erase cache.

It gives you the option to erase cache for the particular directory or whole bucket.
In this case, I have chosen “ /* “ to remove cache for the whole directory.

You have to wait till it completes:

>>Third way, using crossFTP pro:

Select the bucket name and right click on [PRO] Cloudfront Invalidate option.

Note: it is supported on pro versions only so you can buy from here http://www.crossftp.com/purchase.htm

Leave a Reply

Your email address will not be published. Required fields are marked *