Browser caching: interaction between htaccess vs cloudfare settings

#1

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?

#2

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.

#3

Thanks, I hadnt managed to find that article.

1 Like
closed #4

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