Prevent HTML storage if any request has Error 404


First, I didn’t find an APO or Wordpress category at the time of publishing this post. If I’m in the wrong place, please forgive me.

I’m using Cache of Edge to store my Wordpress rendered HTML, I have a suggestion that helps a lot the compatibility with different builders.

In my case it’s Elementor, sometimes the .css is 404, because the post/page has been updated and it’s still generating the .css

But someone accesses it before completion the generation, there is still the .css before the update.

The proposal is:

If any request has a 404 error until the DOM is ready, Do not save it in Edge Cache (HIT), if it is already saved, then clear this HTML from the cache.

Is this possible only on the side of your plugin? With Workers?

Hi @ofm1990, I like to solve problems at their roots. This problem does root from: “a page is published while it’s dependencies are not ready/generated”. Thats a logical error. But the error is not with Cloudflare it’s the way your builder works/builds.

A site shall just be published when all it’s dependencies are created and ready. Fixing this would entirely solve that problem without concealing it.

Also, the way you described will result in a lot of necessary cache flushes which will result in higher load on your server and less Request/HIT ratio. The problem would still exist without Cloudflare: if you call a page, and the linked CSS file is not geenrated yet, it will not render/display normaly.

Additionally to this Cloudflare does not save files in it’s cache on errors anyway. But what you probably want is: not saving the HTML if any of it’s subresources/subrequests results in an error - right?

So implementing a Worker that checks, if all subresources are not returning an error and if, does not cache and even wipe cache would just conceal the problem in my eyes… instead the problem should be fixed at it’s roots (the appication) which is publishing pages while their subresources are not ready yet.

1 Like

Thanks for the well-reasoned answer, it really does seem to be something Elementor has an obligation to address.


You can configure the origin to send a no-cache directive for a 404 (Cloudflare’s default is 5 mins I believe to prevent a DDoS attack vector.) It could be done with workers as well.

In general Cloudflare has no knowledge of the state/status/intent of the origin and relies on it to provide an accurate answer. So @M4rt1n has the ‘right’ response.


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