November 15, 2023
Behind the Screen: Refreshing Your Finance Wisdom on a Cached Web
Hey there, financial explorers!
I hope you’re all keeping your wallets full and your spending savvy. Today, I want to share a little behind-the-scenes story from my own blogger’s toolbox – something I consider might help you in your digital ventures.
So, I jazzed up my website with new tips on investment – all hosted on AWS S3, which is essentially my online vault for website content. I expected my readers to see the changes right away, but turns out, the web can be a bit like an old cassette tape sometimes – it sticks.
You see, when you update your site, sometimes the internet’s memory (what techies call a ‘cache’) clings to the old stuff. It's like when your TV keeps replaying the same old reruns – comfortable but not what you’re looking for.
This is where CloudFront comes in – it’s Amazon’s way of making sure that, no matter where you are in the world, my website loads faster than a kiddo running after the ice cream truck. It keeps copies of my site in different spots globally (imagine mini-warehouses stocked with your site’s goods). Handy, right?
But here's the kicker: when I made changes to my website files on S3, the mini-warehouses didn’t know I’d restocked with fresh content. They were still handing out last season's styles, metaphorically speaking.
To fix this, I had to do something called an ‘invalidation’. It’s a fancy way of saying, “Hey CloudFront, forget what you know and grab the new stuff!” It’s like telling the warehouses to ditch the old stock and display the new line-up.
Let's take a look at the steps to clear the cache for objects in a CloudFront distribution. 🙌🏼
1. Navigate to your AWS CloudFront dashboard and select the CloudFront distribution you want to invalidate.
2. Select the "Invalidations" tab, then click on “Create Invalidation”
3. Create Invalidation
Enter a specific file name, such as 'index.html', in the object path field, or use the wildcard character (/*) to invalidate all files. This action will ensure the most recent files are retrieved from S3.
Note: You can also use AWS cli for invalidation.
aws cloudfront create-invalidation --distribution-id <your distribution id>
— paths “/*”
In short, if your updated website is playing hide and seek, remember it’s probably not gone; it's just cached. A little patience and a manual prompt, and you’ll have your new shiny content smiling back at you.
Keep thrifty and surf safe!