Wordpress + CF Worker
See original GitHub issueHello!
So I just setup a CF Worker using the provided example (see here) and kept everything exactly as-is out of the box.
I am having to use the API config, as I don’t have an option for KV storage at the moment (via the Workers tab, or workers.dev)
Workers KV is currently not available for workers.dev.
I’m noticing that most of my requests (https://willstocks.co.uk) are getting the following response headers applied:
x-html-edge-cache-status: Hit, Refreshed
x-html-edge-cache-version: -1
But if I look in my Workers stats, I’m seeing requests coming in (both cached and uncached (for the pages that I’m visiting for the first time since implementation)):
The x-html-edge-cache-version
never increments up, despite the fact that I have the plugin installed on my WP site. I’m also not seeing the x-HTML-Edge-Cache
header for some reason?
Worth noting, I am also using W3TC on my site, but I’m seeing the headers change on refresh/consecutive visits.
Any ideas? 😁
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (5 by maintainers)
Top GitHub Comments
The service-worker and Cloudflare worker should iteroperate fine. As far as the SW is concerned, the CW is just the web server serving the content. Think of it more like a version of W3TC, just running at the edge.
On Fri, Aug 2, 2019 at 9:54 AM willstocks-tech notifications@github.com wrote:
I can explain parts of it anyway…
The worker serves the cached HTML immediately and then asynchronously updates the cached version from the origin when it doesn’t see the headers from the plugin. That way if the plugin isn’t installed and purge isn’t working it will still stay up to date. That’s what “Hit, Refreshed” refers to. This is likely because of W3TC which serves the HTML from disk directly from the web server and never gets a chance to add the header (which is also why you don’t see it). If you are sure the plugin is installed and purging you can disable the code here.
-1 is normal for the version number when KV isn’t used and it doesn’t change. It is only used with KV.
As far as the worker stats go for subrequests, that’s not unexpected if it is refreshing the cahced items. The main dashboard should have a view of the cache hit rate for the top-level requests.