It seems that the routing worker could be the reason for the issue - the moment I disable it all works as expected. That’s a bit strange as the worker should trigger redirect only for users in Ukraine
Could someone please point me in the right direction on how redirects (URL re-build/re-write) could impact caching?
I have checked with my hosting provider and switched to a default theme + turned off most of the plugins and the only caching-related difference was MISS instead of BYPASS
This leads me to believe that some changes on Cloudflare side provoked the problem, not the site or host
I would appreciate if someone could assist with the matter
As a result of our own troubleshooting, we came to the conclusion that Cloudflare APO is being bypassed (cf-cache-status: BYPASS) when traffic routed via a worker with extremely minimal code (that should simply pass the request to the origin)
First of all, I would like to share publicly my feedback on Cloudflare support.
Without any doubt, handling of this particular case was by far the worst experience I ever had with any IT service provider!
I registered the case with Cloudflare support on 26/03. The case included:
Description with screenshots
Steps to reproduce
Code of the original and simplified workers
Since 26/03:
I sent 25+ messages, at least half of them were chasers and reminders. The longest wait time was 14 (!) days.
In total, I received 11 responses, out of which:
4 were generic
4 were claiming all works as expected
1 blaming Polylang cookie
1 suggesting a workaround (using Cache Rule)
1 combining both (blaming Polylang cookie and suggesting a workaround using Cache Rule)
Not even once did I receive an acknowledgement of the issue, and the case was closed on 25/04 (one month after we opened it) because we downgraded back to a Free plan (as paying for such quality of support was a nonsense).
Funny enough, the workaround suggested by the support team was a shot in the right direction (I will cover this in the next post), however:
it was incomplete/insufficient
it was confirming my assumption that the issue was on the Cloudflare end.
As the issue wasn’t acknowledged/resolved at the Cloudflare side, we had to do the following:
Damage control
I discovered that the more specific worker routes override the generic ones, so we excluded static resources and 1 of 2 language locales coming through the worker. That was more of a damage control measure, but still, we instantly saw an improvement!
This also invalidated the CF support’s claim that the issue was provoked by the Polylang cookie (as the locale where the worker wasn’t triggered had exactly the same plugins/theme/settings as the other one)
Workaround implementation - Transform rule Deletion of pll_language cookie with the Transform rule of amendment of the worker didn’t change the behaviour of the CF cache (still BYPASS)
Workaround implementation - Cache rule (suggested by CF support)
For the remaining language locale (passing via the worker), we created a Cache Rule that was setting an attribute Eligible for Cache.
By itself, it was insufficient.
So, we added Edge TTL and Browser TTL to the same root and saw a stable HIT! Over the last 24 hours this solution was working well, and the %% of cached content served jumped to over 80%, but we will have to keep an eye on it as it’s not a fix, but a workaround.
Summary: looks like APO cache is occasionally glitching when the request is coming through the Worker Route. Most likely, this could be related to either:
changes in the cache key/adding CF-specific headers, and/or
loss of TTL headers somewhere between the worker and APO cache, and/or
something else on the CF side
We can’t be sure when and if Cloudflare will decide to pay attention to this case, but we decided to share this solution with the public.