Changing the default cloudflare behavoir

I have a WordPress website and I have set up Cloudflare CDN with APO for caching. I have also set up a page rule to ‘Cache Everything’ for the entire website. However, the cache is not loading for logged-in users and the response header shows a status of 200 instead of 304 and the cf-cache-status shows bypass. It seems that the default Cloudflare behavior has a bypass rule for logged-in users. How can I ensure that the cache loads for both logged-in and logged-out users? Most pages on the website are not specific to user content, I want all pages to be loaded from Cloudflare and make a few exception for the user specific pages. I am on the PRO plan. Many thanks for your help.

1 Like

On the same page rule that you set Cache Everything, add the setting Edge TTL to an amount of time of your preference. That should make Cloudflare to ignore the logged-in cookie.

Please understand that, if the first visit to a page is from a logged-in visitor, some information that should only be visible to them, will also be visible to other viewers. For instance, if a user has set that they want to see the admin bar on top of the page, the admin bar with their username will be cached and subsequently served to all visitors for that URL.

So make sure you set your WordPress installation in a way that, for all pages for which the Cache Everything page rule is set, there’s not any dynamic content based on login status.

1 Like

Thanks for your quick reply. Your point about logged-in visitors is indeed something I need to avoid.

However, I noticed that my page rules do not seem to have any effect.
I tested it with setting all pages of my website to Cache Level “Bypass”, but logged out users still get the cf-cache-status: HIT. I set up a page rule for my domain with /* and cleared the cache in Cloudflare and my browser, but it still loaded the cache for the page.

Regarding my endeavour to cache pages for logged in users:
WP Rocket does have a user cache feature. So my current idea is to cache my pages with WP Rocket and get the code and other files from Cloudflare. Is this possible and do you have any idea how to set this up?

Thanks again for your effort in guiding me.

How come then you went from, in your first post, logged-in users not being cached, to logged-in users being cached and you can’t purge it? Did you change other settings? You did not say how is it that your main concern shifted completely. If page rules to bypass cache are not being effective, make sure they are placed in the proper order.

I’m not familiar with WP Rocket, but I’d refer you to Cloudflare documentation about APO, which does contain pointers to compatible WordPress plugins. Also, you may want to search this community for “apo wp rocket” and read past posts about this combination.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.