question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wordpress + CF Worker

See original GitHub issue

Hello!

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)): image

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:open
  • Created 4 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
pmeenancommented, Aug 2, 2019

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:

Thanks @pmeenan https://github.com/pmeenan! Updated Page Rule and have applied, will monitor from there as well 😃

As an aside, I will log a ticket with the guys at W3TC to see if they can add some form of support for this implementation.

One final question (slightly off topic!), my site runs a service-worker (network first) - is there anything that needs to be included within that so that everything runs perfectly alongside the CF Worker?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cloudflare/worker-examples/issues/41?email_source=notifications&email_token=AADMOBIH4GFJERZSLPNJUKLQCQ4DHA5CNFSM4II4T432YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3NZ7VY#issuecomment-517709783, or mute the thread https://github.com/notifications/unsubscribe-auth/AADMOBMWSE3NYZJD3VHDC33QCQ4DHANCNFSM4II4T43Q .

1reaction
pmeenancommented, Aug 2, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building Automatic Platform Optimization for WordPress using ...
The post will explain how Automatic Platform Optimization combines the best qualities of the regular Cloudflare cache with Workers KV to improve ...
Read more >
I moved my WordPress website to Cloudflare Workers and ...
I started wondering about the workers' speed as it is one of the main selling points of it. I decided to move my...
Read more >
CF Worker? | WordPress.org
Hi, the plugin is compatible with CF Workers. In the next version there will also be an option that uses them to command...
Read more >
Basic Cloudflare Worker that allows efficient page caching for ...
Basic Cloudflare Worker that allows efficient page caching for Wordpress websites - cf-wp-cache-worker.js.
Read more >
How to Set up Cloudflare APO for WordPress - Kinsta
This makes Workers KV a prime candidate for speeding up WordPress sites ... As you can see, the cf-cache-status , cf-apo-via , cf-edge-cache ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found