Wondering how to prevent CloudFront from caching certain files? We can help you.
At Bobcares we assist our customers with several AWS queries as part of our AWS Support Services for AWS users, and online service providers.
Today, let us see how our Support Techs resolve this CloudFront issue.
How to prevent CloudFront from caching certain files?
Today, let us see the configuration used by our Support Techs to prevent caching.
Configuration on the origin
On your custom origin web server application, add Cache-Control no-cache, no-store, or private directives to the objects that you don’t want CloudFront to cache.
Else add Expires directives to the objects that you don’t want CloudFront to cache.
If you’re using Amazon Simple Storage Service as the origin, you can add certain Cache-Control headers using object metadata.
Configuration on the distribution
- Firstly, open the CloudFront console.
- From your list of CloudFront distributions, choose the distribution that you want to modify.
- Then, choose the Behaviors tab.
- If you already have a cache behavior for the objects that you don’t want CloudFront to cache, select the cache behavior and choose Edit.
- To create a new cache behavior, choose Create Behavior.
- For Cache and origin request settings, select Use legacy cache settings.
- In the cache behavior’s settings, enter the following to prevent caching:
In Object Caching, select Customize.
For Minimum TTL, enter 0.
For Maximum TTL, enter 0.
- Then, choose Yes.
- Finally, edit to save the changes that you made.
[Need assistance with CloudFront? We are available 24*7]
Conclusion
Today, we saw how our Support Techs prevent CloudFront from caching certain files.
0 Comments