Search code examples
amazon-web-servicesamazon-s3amazon-cloudfrontaws-codepipeline

S3 static hosting still showing the old version of the Application


We have a code pipeline that has a webhook with a git branch.

Every time a push has been made to that branch a code pipeline is triggered.

source -> build -> DeployToDevS3 -> DeployToStgS3.

This flow was working great until the last time I checked.

Now the issue is Deployment to dev s3 and stage are showing a success message and even the file within them is showing the latest modification.

The Development site is showing the updated code. Whereas the staging site is showing the old code.

Both have a cloud front in front of them. The stage distribution is still showing the old version if I access the domain name

Could anyone help me out of this


Solution

  • Based on the comments.

    Default CloudFront TTL is 24h. To force serving new content before cache expires, you have to invalidate the cache, using one of the two methods:

    • Invalidate the file from edge caches using create-invalidation API call.
    • Use file versioning to serve a different version of the file that has a different name.

    Alternatively, for future use, one can reduce default TTL from 24h to something more suitable, e.g. 6h.