Skip to content

Fixing WordPress CSS Caching Issues with Cloudflare and Versioned Assets

I spent hours chasing a strange issue where my stylesheet looked fine in Chrome but broke in Safari and Waterfox. After digging into Nginx configs and testing direct CSS loads, I realized Cloudflare was serving an outdated, truncated version of my file. Clearing the Cloudflare cache fixed it, but I needed a permanent solution. The fix was to auto-version assets in WordPress using `filemtime()`, which appends a unique query string whenever CSS or JS files are modified. This forces browsers and Cloudflare to always fetch the latest copy. Now the site’s styling works reliably across all browsers without manual cache purges.

Published incompleted