Bacancy Technology
Bacancy Technology represents the connected world, offering innovative and customer-centric information technology experiences, enabling Enterprises, Associates and the Society to Rise™.
12+
Countries where we have happy customers
1050+
Agile enabled employees
06
World wide offices
12+
Years of Experience
05
Agile Coaches
14
Certified Scrum Masters
1000+
Clients projects
1458
Happy customers
Artificial Intelligence
Machine Learning
Salesforce
Microsoft
SAP
October 21, 2024
The issue occurs when S3 metadata (e.g., Content-Type) is updated, but CloudFront continues serving cached content with outdated metadata, like application/x-mp4 instead of video/mp4. CloudFront serves the old cached version even after manual updates or running a cron job.
CloudFront caches both the content and metadata (like Content-Type) at its edge locations. Once cached, CloudFront will continue serving this stale data until:
a. Manually Invalidate CloudFront Cache
-> AWS Console Steps:
-> AWS CLI Example:
aws cloudfront create-invalidation \
--distribution-id YOUR_DISTRIBUTION_ID \
--paths "/path/to/video.mp4"
b. Use Proper Cache-Control Headers
Ensure S3 objects have correct Cache-Control headers to define how long objects should be cached by CloudFront. Example:
Cache-Control: max-age=60
c. Automate Invalidation in Cron Job
Update your cron job script to include CloudFront cache invalidation each time it updates metadata.