AWS CloudFront not updating with newer content - amazon-web-services

I've hosted a website on S3, with CloudFront over the top. Now I've changed some code and try to update the newer content but I'm unable to achieve it.
I read somewhere that after invalidation it works but in my case even after invalidation I'm unable to update it.
Could someone please tell me the exact steps to update the new content in CloudFront?

You need to be sure that you're using a wildcard character or explicitly invalidating the object you updated. After the invalidation completes, you need to do a hard reload of your webpage by pressing CTRL+F5 (Thanks Tom) or open the window in private browsing. This will ensure your local cache isn't the issue.
CloudFront Invalidation Example
Here's some documentation from AWS regarding invalidations.
http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html

Related

Continuous Delivery issues with S3 and AWS CloudFront

I'm building out a series of content websites, and I've built a working CodePipeline that allows me to push edits to HTML files on github that instantly reflect in the S3 bucket, and consequently on the live website.
I created a cloudfront distro to get HTTPS for my website. The certificate and distro work fine, and it populates with my index.html in my S3 bucket, but the changes made via my github pipeline to the S3 bucket are reflected in the S3 bucket but not the CloudFront Distribution.
From what I've read, the edge locations used in cloudfront don't update their caches super often, and when they do, they might not update the edited index.html file because it has the same name as the old version.
I don't want to manually rename my index.html file in S3 every time one of my writers needs to post a top 10 Tractor Brands article or implement an experimental, low-effort clickbait idea, so that's pretty much off the table.
My overall objective is to build something where teams can quickly add an article with a few images to the website that goes live in minutes, and I've been able to do it so far but not with HTTPS.
If any of you know a good way of instantly updating CloudFront Distributions without changing file names, that would be great. Othterwise I'll probably have to start over because I need my sites secured and the ability to update them instantly.
You people are awesome. Thanks a million for any help.
You need to invalidate files from the edge caches. It's a simple and quick process.
You can automate the process yourself in your pipeline, or you could potentially use a third-party tool such as aws-cloudfront-auto-invalidator.

How to set no cache AT ALL on AWS S3?

I started to use AWS S3 to provide a fast way to my users download the installation files of my Win32 apps. Each install file has about 60MB and the download it's working very fast.
However when i upload a new version of the app, S3 keeps serving the old file instead ! I just rename the old file and upload the new version with the same name of the old. After i upload, when i try to download, the old version is downloaded instead.
I searched for some solutions and here is what i tried :
Edited all TTL values on cloudfrond to 0
Edited the metadata 'Cache-control' with the value 'max-age=0' for each file on the bucket
None of these fixed the issue, AWS keeps serving the old file instead of the new !
Often i will upload new versions, so i need that when the users try to download, S3 never use cache at all.
Please help.
I think this behavior might be because S3 uses an eventually consistent model, meaning that updates and deletes will propagate eventually but it is not guaranteed that this happens immediately, or even within a specific amount of time. (see here for the specifics of their consistency approach). Specifically, they say "Amazon S3 offers eventual consistency for overwrite PUTS and DELETES in all Regions" and I think the case you're describing would be an overwrite PUT. There appears to be a good answer on a similar issue here: How long does it take for AWS S3 to save and load an item? which touches on the consistency issue and how to get around it, hopefully that's helpful

AWS CloudFront website not being updated

Our website hosted on CloudFront has not been updated for almost 24 hours now.
The CloudFront invalidation updated a few of the files. I can see on S3 all of the files have been updated. Performing a GET on these files I can see the timestamps are all correct except for one of the files (a javascript minified file called app.min.js) which still has an old timestamp on it. However, looking at S3, the app.min.js file has the correct updated timestamp. Forcing a no cache on the file, the app.min.js still reflects the old file.
Does anyone have any suggestions on what could be happening here?
Your files are still being cached somewhere. If it's not cached in CloudFront, it may be cached in your browser or somewhere else between CloudFront and you.
Invalidating the CloudFront distribution does not invalidate the cache in your browser. So make sure you're using a fresh browser to test this. Better yet, use curl.
Invalidate CloudFront again
Restart your browser
Use a different browser
Use a different computer
Use curl to avoid local caches
Do anything to eliminate the possibility of hitting a cached version.
Also:
Adding "no cache" to a file on S3 won't have any effect on the cached version in CloudFront. You'll need to invalidate the cache again to force CloudFront to get the new version.
The default TTL for CloudFront is 24 hours. So once it hits 24 hours, it should re-get the file from the origin. You can look at the headers to see how long it will be before the TTL runs out.

Why is root domain name served by Cloudfront taking me to http://aws.amazon.com/

I have a domain (albunack.net) configured to use Cloudfront (via A record), its almost working.
Any request I make such as:
http://albunack.net/style/albunack.css
http://albunack.net/artist/ae65c507-d9a0-4d42-9a6c-2b1f82158b9f
all work fine, and I can see that Cloudfront is seeing them
but simply entering the domain
http://albunack.net
is taking me to
http://aws.amazon.com/ !
I cannot understand why, especially since it was all working great but I had to disable delete the Cloudfront instance (because there was to much data that needed invalidating) and create a new Cloudfront distribtion (which I thought I had done identically)
Update
http://albunack.net should take you to http://albunack.net/index.jsp. If you bypass Cloudfront and go directly to the EB server it does do that. Reviewing my CloudFront distrubution I had not set a default root object but setting it to index.jsp and redeploying didnt work, nor did setting it to /index.jsp so Im out of ideas.

Updating objects for static site on AWS and not seeing the results appear in browser

I am having two issues with using AWS S3 and AWS Cloud front services to deploy a static site. The first problem occurring is that I'm not seeing the changes I make to my index.html page when I look up http://.point.plumbing . However if I go to my bucket and access the Object: index.html and click on the link you will see the desired changes in effect https://s3-us-west-2.amazonaws.com/point.plumbing/index.html
The second issue that I am having is that I seem to be getting this error Failed to load resource: the server responded with a status of 403 (Forbidden) http://www.point.plumbing/fontkit/avenir_55_oblique-webfont.woff2the error is telling me that the server cant load some of my fonts I want on http://.point.plumbing
On the services page if you click on the icons you will see that I am not getting the font avenirmedium, sans-serif to load.
I've spent quite a bit of time trouble shooting these issues and the closest I have come to a solution is with this link. http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ReplacingObjectsSameName.html
Is the reason why I'm getting errors and not seeing the desired changes arrive on http://.point.plumbing is because my objects cache is not refreshed for 24 hours?
Any help would be greatly appreciated.
First of all, I noticed you said your endpoint is https://s3-us-west-2.amazonaws.com/point.plumbing. Check the console, your web endpoint is actually point.plumbing.s3-website-us-west-2.amazonaws.com (I assume point.plumbing is something with a valid top level domain).
If I'm understanding correctly, you said you aren't seeing changes to the HTML when you view it via CloudFront. This is because CloudFront caches your files - by default for 24 hours. In order to see updates, you need to specify a shorter TTL via HTTP headers in the Object Metadata or issue an API command to Invalidate the objects. This takes 10 to 15 minutes to propagate and will start costing you money after the first 1000 objects per month.
About the fonts, I'm not sure but sounds like maybe a permissions issue. Make sure the object has permissions for public-read or set public get-object permissions on the bucket.