7

After hosting website on s3, how can we make changes in text in its webpages. I deleted older html files from bucket and uploaded new files by same name with updated text in the code. But no changes were reflected after refreshing those webpages.

Is there is any other way to update webpages of a website already hosted on s3 ? If so would somebody please post steps here to make those updates ? TIA.

DS_DS
  • 83
  • 1
  • 1
  • 4

2 Answers2

21

I notice you have CloudFront in your tags so that is most likely the issue. When you upload a file to S3, CloudFront won't know about it right away if it's an existing file. Instead it's set to a default of 24 hours where it checks your origin (in this case your S3 bucket) to see if any changes have been made and if it needs to update the cache. There are a few ways to make it update the cache for those files:

  • Using files with versions in their names, and updating links. The downside is that you have to make more changes than normal to get this to work.
  • Invalidating the cache. This is not what Amazon recommends, but is nonetheless a quick way to make the cache pickup new changes right away. Note that there can be charges if you do a lot of invalidations:

No additional charge for the first 1,000 paths requested for invalidation each month. Thereafter, $0.005 per path requested for invalidation

Setting CloudFront behaviors

Here is where you can assign a path (individual file, folders, etc.) and adjust certain properties. One of them is the TTL(Time To Live) of the path in question. If you make the TTL a smaller value CloudFront will pickup changes more quickly. However since you have an S3 origin note that you'll have to deal with request allocations. Also CloudFront will need some time to distribute these changes to all the edge servers.

Hope this helps.

Chris White
  • 1,409
  • 8
  • 10
  • *"Also CloudFront will need some time to distribute these changes to all the edge servers."* Which "changes" does this statement refer to? Changes to the cache behavior settings? Or changes to objects? Note also that creating an invalidation request for everything in a distribution by using invalidation path `*` or `/*` only counts as 1 invalidation towards the free allocation of 1000 per month. The number of objects evicted isn't a factor in the cost when done this way. This capability was added after CloudFront initially launched. – Michael - sqlbot Jul 02 '17 at 12:31
  • @Michael-sqlbot I'm referring to the invalidation. If I invalidate I get an ID back and it changes to an In-Progress status. I do thank you for the clarification on the invalidation allocations. This is simply to note that there is a chance for being charged, albeit a very low cost. I tend to do invalidations myself as it's fairly rare for me to change existing files. – Chris White Jul 02 '17 at 14:46
  • There's an occasional misconception that changed objects are "pushed" to CloudFront, resulting in a [replication delay](https://stackoverflow.com/a/35541525/1695906), which of course isn't what happens. I didn't think you were saying that, but wanted to verify. Thanks for clarifying. – Michael - sqlbot Jul 02 '17 at 17:50
0

In case you are not using cloud-front, but just a normal static S3 website: check if your browser may be caching the pages.

Chrome at least does. So, updating the pages in S3 might not be visible until you clear the browser cache.

In chrome you can remove the cache as follows:

  • Open settings
  • Search for 'cache'
  • and remove pictures & files.
Bart Jonk
  • 365
  • 3
  • 14