Restart button for static files

As a developer, I am always adding improvements to my site or creating new areas on the site. I recently added a new area for articles and I was surprised not to find an option in the dashboard to ask Cloudflare to delete my old CSS files and index the new one that I just uploaded to the server.

I understand that there is the less romantic option in which I can add an id to the name to change every time I have a new version, but I expect or think that it is also a professional way to announce that we have a new version of code to replace the old one.

99% of Cloudflare’s clients are dynamic sites that constantly change their content, but once indexed in Cloudflare’s server network, do they stay that way forever?

It sounds like you’re talking about Cloudflare Cache, and purging it? Index/indexing isn’t how I would describe it, the cache is more like a key value store, which has its own Cache TTLs (Time to Live) and the key being the url (after normalization/other settings you can apply like cache level), and the value being the data.

There are various options to purge files from the cache:

Almost every dynamic site has some static content (css, etc) that is cachable, so I wouldn’t say the percentage is nearly that high. Regardless, Cache does expire, yes. The Cache TTL you return to Cloudflare in the cache-control headers (or override/set with Page Rules or Cache Rules) is the max amount of time an item will remain in cache, but items may be evicted earlier if not accessed frequently, and Cloudflare cache is by default per location. You can identify if an item is cache via the CF-Cache-Status response header, and for how long it has been cached by the age header

3 Likes

If a site is 100% dynamic or the same site has dynamic content in addition to static files, it means that it is a dynamic site, and vice versa if a static site has only static content, it means that it is a static site. At least that’s how I learned about websites.

Back to my problem. I will try to explain differently: I have a new version of the CSS file. How do I delete the old CSS file from Cloudflare and load the new file that I just made?

Cloudflare is a Pull CDN. When someone requests a CSS file, Cloudflare will see if already has it in cache. If not, then it will get it from the origin server, and keep it until TTL Expires or it’s not popular enough to stay in cache.

If you change that file on your server, you’ll need to Purge it from Cloudflare – either by the URL itself, or as part of Purge Everything:

1 Like

That’s what you need. You can follow @Chaika and @sdayman advice to purge Cloudflare cache for the CSS file, but you won’t be able to purge the CSS file that has been cached by browsers if the filename doesn’t change. Add a versioning system to your origin, or make sure your send your CSS file with a Cache-Control header that indicates it is dynamic, which will of course impact the performance of your website.

4 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.