Browser caching: interaction between htaccess vs cloudfare settings

My htaccess file instructs browsers to cache js/css for a month, and images and fonts for a year.
Cloudfare also has browser caching settings. It set to one month now.

Do cloudfare settings override htaccess instructions?
Should I even care, if cloudfare distributes images for me?

You can make Cloudflare respect your server cache instructions by going to Caching > Browser Cache Expiration and set it to “Respect Existing Headers”. However, if you chose instead a set a specific time, like one month, Cloudflare will pass along the highest time between what’s in the headers sent by your server and this one-month setting. So if your .htaccess has it to cache JS files for one year, that will be respected.

https://support.cloudflare.com/hc/en-us/articles/200168276-What-does-the-Browser-Cache-Expiration-do-

Thanks, I hadnt managed to find that article.

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.