We have a picture in an AWS S3 bucket which updated, but AWS CloudFront still returns its old version.
To remove it from the CloudFront cache – need to create an object’s invalidation.
It can be created via AWS Console web-UI or by using AWS CLI.
In the AWS Console – go to the desired distribution and click the Create invalidation button:
And set to clear everything under the courses/images/*
:
Or – create it using the AWS CLI:
aws --profile bm-backend cloudfront create-invalidation --distribution-id E3V72S54L4XFN5 --paths "/courses/images/youthful_face.png"
{
"Location": "https://cloudfront.amazonaws.com/2019-03-26/distribution/E3V72S54L4XFN5/invalidation/I1TU7YRJRXCOAF",
"Invalidation": {
"Id": "I1TU7YRJRXCOAF",
"Status": "InProgress",
"CreateTime": "2019-09-27T13:16:31.089Z",
"InvalidationBatch": {
"Paths": {
"Quantity": 1,
"Items": [
"/courses/images/youthful_face.png"
]
},
"CallerReference": "cli-1569590190-500229"
}
}
}
Clean up process started:
By default – CloudFront will store objects in its cache during 24 hours, but this can be changed in the objects TTL settings:
Done.