Html-Edge-Cache worker is not working anymore

There is this edge cache html worker plugin/code that is developed by a cloudflare team member.

I have successfully added it a few weeks ago, it nicely purged the cache when i added a new post, so i could enable caching for everything, however, for some reason it stopped working (i have been tweaking with my site for a while so i am not sure what caused it)

any reason for why it could have stopped working? Its not in the headers list when i check any page on gtmetrix or pingdom or anything like that.

Thank you so much for your help.

if i remember correctly it was x-html-edge-cache

the site is nullfud(.)com if u need to check gtmetrix

edit: now my domain name has a the x-html-edge-cache header, but no other file does (yes i used /* after the domain)

when i post a new post it doesnt clear the cache (it previously did)

i have tried redoing the worker, disabling wp rocket, and wordfence, nothing helped, i am really thankful for any help.

edit2: also tried non kv workers, didnt help.

So it’s working, but too well, as it’s not clearing the cache.

Do you still have the plugin installed?

1 Like

yes i do (i was waiting for your reply, saw posts related to that with your replies in it, you seem to know how this thing should work)

It’s working fine for me, I get the header “x-html-edge-cache-status: Hit, Refreshed”.

The example avoids the caching when you’re logged in (there’s a Wordpress cookie present) - could this explain it? Test in an incognito window if you don’t want to log out of your main window, then you can test not logged in at the same time.

Also if you’ve got the browser debug tools open (which presumably you do, if you’re checking headers) then make sure that “Disable cache” isn’t ticked on the Network tab, as this sends headers that tells the worker not to use the cache as well.

EDIT: Sorry, I didn’t read through all of your edits properly, this doesn’t really answer your latest question.

I have disabled cache everything, and now i am only caching the wp content folder, this way i have no problems with cache purges on new posts, plus my TTFB seems to have also improved, i get a sub 2 sec (even sub 1 sec sometimes) loading time most of the time, should i just leave it at that? I am not a professional so i am not sure if i can further improve it.

Do the files not suppose to have x-html-edge-cache-status headers, only the main url? I get it on the main url but not for anything under it on the waterfall chart.

Thank you so much for your time!

The page cache worker is specifically for caching HTML content, specifically the mime-type “text/html”. If you look at the example worker (I don’t know if you’ve modified it much) you can see this on lines 61, 175 and 280.

I’m experimenting with this feature myself, but am unsure what is the benefit of using X-HTML-Cache as opposed to the Cache-Everything Page Rule?

Any insight is appreciated. Thanks.

1 Like

It just gives you better control, if you use a Page Rule then it’s all or nothing, to update you have to purge the whole cache. Using this worker you can purge individual pages, as each one is stored in the KV separately. This is especially cool if you’re using Wordpress as there’s a plugin that will automatically purge a page from the cache when it’s updated, making it a seamless experience for non-techie users once setup.

1 Like

Thanks for quick reply.

The Cloudflare plugin and API have the individual purge though - although it’s manual.

Is it that this feature is automatic when using KV store that’s the real benefit?

I think you have the individual purge option on the Pro plan, but not the Free plan, if I remember correctly. So paying for workers can be cheaper than paying for the Pro plan, if this is the only feature that you’re looking for. That might have changed since I last looked though, not sure.

Yes, it’s available on free, so possibly changed since you first noticed. Cloudflare often upgrade the free tier as things progress.

As per Pat Meenan’s notes: it only purges HTML content when changes are detected. (as long as KV is used rather than the API)

So it can purge the HTML on a per page basis rather than a full page purge that might have images, etc. Basically it’s as delicate as we can get regarding purging.

Everything works fine now I’ve woken up and installed the correct plugin. :slight_smile:

My x-html-edge-cache version numbers are incrementing too!

Thanks for your help, have a great weekend!