close

March 2024 only! Join our Discord free of charge.

Slick­Stack
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.

About the Author

Jesse Nickles

Jesse is the lead developer for the SlickStack project and also for HoverCraft, the accompanying free WordPress theme. He has been customizing WordPress for both personal websites and SEO clients for over 15+ years, with a focus on simplicity and longevity.

Tags:

Thanks to our generous sponsors for their support!