I recently moved to Cloudflare from another CDN service and I’m trying to diagnose a behavior related to bypass cache and WP Rocket. I have a rule set up to bypass cache for logged-in cookie. My issue is this seems to send the request to the origin server (which I want), but also bypass the local/WP Rocket cache and build the request from scratch. My desired behavior is to send the logged-in user to the origin, if there is a cached page (in the WP Rocket logged-in cache) to serve that. With the previous CDN, in this scenario, the pages would load in 300-500ms from the local cache, with CF, I’m seeing 700ms to server and 1.65 seconds download content. The previous CDN had “do not cache” and “bypass cache” as options, but their “bypass cache” worked in this scenario.
As a test, I put up a static (not in the WP system) HTML page on the server. With the logged-in cookie, I connect to that page in 300ms.
The fast static page response has this header - x-powered-by: WP Rocket/3.11.5.
The slow WP pages have this header - x-powered-by: PHP/7.4.33
I have followed WP Rocket’s CF config list and enabled the CF add-on. My question is - is there some setting I’m missing on either CF or WP Rocket side that’s telling WP Rocket to bypass the local cache? Or is CF “bypass cache” also telling WP Rocket no cache? And if the latter, is there a Worker or some other method I should use?
This doesn’t seem to be an issue created directly by Cloudflare. When you set your Cloudflare cache to bypass cache for logged-in users, the request is passed to the origin and it’s up to the origin to handle any caching instruction. However…
Depending on how much you have changed the default configuration in Cloudflare, you may want to investigate whether URLs are being impacted by either a) Workers, if you have created any; or b) Transform Rules (especially the Modify Request Headers kind), same.
I’m not familiar with WP-Rocket, but I’ve used bypass cache on cookie with two other WP cache plugins (LiteSpeed Cache, and WP Super Cache), and didn’t have the issue you’re reporting. Locally cached by each logged-in user worked as expected.
No, Cloudflare passes the request unaltered to the origin. Changing any cache headers in the way to the origin or altering the cookie wouldn’t be the expected behavior.
Thanks for the reply on this - no Workers installed. I think this is a server issue, I confirmed the cache is coming from the static cache (by changing the file manually) and then tried another cache plugin with similar results.
I did some testing to try to solve this, with different cache plugins, to determine it’s not the cache plugin. I toggled many of the optimizations in CF and didn’t find much difference…
“hello world” fresh WP install no plugins only cache, same server but separate domain, not CF proxy: 300-500ms
“hello world” fresh WP install no plugins only cache, CF-proxy: 1-2 seconds
static HTML file CF proxy: 300-500ms
static HTML file non-CF proxy: 300-500ms
live site, WP cached file, CF proxy: 2-3 seconds
Here’s some timing from those:
cache, non CF proxy:
here’s a live site CF proxy, one aspect I don’t understand is sometimes the ‘waiting for server’ is very long, but also the “content download” can be the issue as well, all these examples are 20-40k HTML files.
You seem to have changed the topic from your initial question (Is Cloudflare making origin server to generate page from scratch when I set it to bypass cache on cookie?) to a more generic concern about speed in general and what causes the perceived slowness in a proxied setting.
In what concerns the first question you raised, are you satisfied Cloudflare is not causing the issue? Regardless of speed, have you confirmed you can fetch a logged-in cached page from origin when Cloudflare bypasses its own cache?
As for the second line of investigation, there are many issues that could be affecting the speed. Among them, network traffic, ISP peering, local firewall and server configuration. Please this community as claims of proxy slowness are rather frequent and the reasons vary almost as much as the users posting them. After you’ve read enough about what can be causing the perceived slowness, if you have any specific point to make or ask about, feel free to bring them here and this community will be glad to help.
Apologies - I probably should have waited a step or two into my inquiry before posting, if I could edit the title, I would to “Cached WP pages much slower than static HTML on same server” or something to make it more general.
No worries. I believe you can actually edit the title if you hit the button on the initial post. But you still need to for similar topics and investigate further to make sure this slowness is not caused by your own origin and/or ISP.