How to Clear Cloudfront Cache: Purge and Refresh Files

How to Clear Cloudfront Cache: Purge and Refresh Files
How to Clear Cloudfront Cache: Purge and Refresh Files

So how can you to clear/flush Amazon Cloudfront cache and purge files to empty cache across the Amazon CDN? This will refresh files and update your website look and content. I use their amazingly fast CDN service and had some difficulty in finding a way to purge files. My blog would simply not refresh content cached in Cloudfront even after changing files.

Here is the way so you don’t have to get stuck with flushing Cloudfront cache!

What is Amazon Cloudfront Caching

Cloudfront is the content delivery network service of Amazon Web Services (AWS) which allows users to host files that can be accessed at the fastest speed from server nearest to them. Typically CDN‘s help to make sites faster as the content is delivered at a much faster speed from geographically nearby servers, rather than searching for that content from your webhosting server.

I have been using Cloudflare CDN for quite some time but off and on over the years. Recently after switching to my superfast A2 hosting, I decided to use the Amazon Cloudfront CDN network to further speed up my website caching across the world.

Now the initial setup might seem a little tedious for beginners – with first creating a bucket in S3 (which is the simple storage service of Amazon, where we backup websites) and then linking it to create a cloud distribution network with Cloudfront with bucket policy, etc. and after reading of many guides and manuals.

Purge Cloudfront Cache

However, I found it even more daunting than once I uploaded new versions of the images or CSS files they would simply fail to refresh on our website.  But then that is what the purpose of the CDN is that it will host the content and cache it across various worldwide servers.

So how do you clear CloudFront cache and replace these old files to refresh the content that you uploaded in the S3 bucket?

Amazon Cloudfront Invalidation

So they call the processes to empty cache as Invalidation!

I am not sure why they can’t use simple easy to understand language like clear cache or flush cache or purge files which would make it much more user-friendly and more easy to understand. There would be no need to write such an article if it was so easy to find.

A huge advantage of this process is you can invalidate particular files or folders which you want to refresh or delete rather than press a single ‘clear cache button’ and clear the entire S3 bucket across the network.

For simple bloggers who hold a limited number of files such as theme logos, theme CSS files or maybe some social image sharing buttons it would not be much of a difference. But if someone is hosting a huge network of resources, then such a one-click power flush button would lead to usage of a lot of resources and maybe it is not required to simply refresh one file.

How to Refresh Cloudfront Cache?

  1. Go to your Cloudfront distribution > Click invalidations tab
  2. Type folder or a specific image which you want to invalidate
  3. That’s it… Cloudfront will invalidate this content and grab the fresh new files from the S3 bucket and then refresh and cache it across their networks.
  4. It also logs the history of past invalidations, so you can simply copy the request and do repeated cache purges if you want to keep refreshing particular files frequently.
  5. Test and see that the new files are working now.

source –

RSS Latest Press Release

  • Confort Prestige | Climatisation & Chauffage Announces HVAC Services For Improved Energy Efficiency
    TERREBONNE, QUEBEC- NOVEMBER 14, 2021- Premier heating and cooling company Confort Prestige is excited to share HVAC solutions with domestic customers in the Terrebonne area. These services aim to save customers money on their heating and cooling expenses throughout the year.   Since its debut, Confort Prestige has been committed to customer service. This starts […]
  • Hundreds of Car and Truck Parts Available from Salvage Specialist
    Morganville, NJ – When it comes to finding an auto part for a foreign or domestic vehicle, Trilenium Auto Salvage usually has the answer.   The Morganville, NJ salvage specialist has hundreds, if not thousands, of parts and components at its Tennent Rd premises available.   Trilenium Auto Salvage is one of the busiest salvage specialists […]
  • Flowsent Weed Delivery Offers the Fastest Weed Delivery Service in the Bay Area
    Bay Area, CA - As it becomes easier to get cannabis in different stores and online, weed delivery in Oakland, San Francisco, and other Bay Area cities are becoming more common. People are looking for the easiest way to get their hands on high-quality, safe cannabis, and nothing beats direct to your door.    Many […]
  • Cannamazoo Now Offering the Top Cannabis Concentrates in Michigan
    What are Cannabis Concentrates, Oils, and Extracts?   Kalamazoo, MI - You may be familiar with recreational cannabis in its usual form, but have you ever tried extracts, oils, and concentrates? Each of these forms offers unique effects and benefits that smoking cannabis flowers can't provide. Simple dosing, cleaner effects, and better taste are just […]