Join our Discord server for free support, and star our GitHub repo too!

SlickStack
Lightning-fast WordPress on Nginx

Force Cloudflare cache HTML files

By default SlickStack sets Cache-Control headers on .html files:

 

location ~* \.(html)$ {
try_files $uri $uri/ /index.php?$args;
set $cachecontrol “public, max-age=691200”;
}

 

However, Cloudflare considers .html files as dynamic content and they will strip out etag and content-length headers from SlickStack… Cloudflare does NOT strip the cache-control header, however it effectively ignores it and refuses to cache your .html files on the edge (in their CDN), you will see:

 

cf-cache-status DYNAMIC

 

If you want to force Cloudflare to cache .html files you need to add a Page Rule for all .html files that says Cache Everything and then Edge TTL of your choice, for example 1 month.

Last modified on September 26th, 2022