Cache Rules and Best Practise for Wordpress

I am new to Cloudflare.

I was having issues with non-logged-in users being shown the top admin bar.

This was due to a page rule I had to cache-everything for .com/*

I have turned that off now and everything is OK.

However, in the now closed thread, @sdayman said:

That’s why I recommended against browsing the site while you’re logged in. The next visitors will see that, even if they’re not logged in.

Thankfully, since this thread from four years ago, Cache Rules will let you cache if current cookies are NOT present, much like Biz/Ent plan users were able to do years ago.

2 questions:

  1. With the Cache Rules, so is “best practice” to set the page rule cache-everything for .com/*, AND then to exclude cookies from cache with something like this rule:

  1. Is it still recommended not to browse the site while logged in? That seems like a pretty crazy requirement to use Cloudflare and something that needs to be noted/stated much more prominently.

You should create a Cache Rule to replace the Page Rule, not to use both. A Cache Rule gives you a lot more flexibility and you can set in one rule exceptions that would take more than one Page Rule to accomplish.

A typical Cache Rule for a WordPress website to replace a Cache-Everything Page Rule could look like:

Then
Eligible for Cache

Something like that would work for an installation with the default WordPress Permalink structure, where front and pages always end with “/”. You’d of course need to adjust that Cache Rule if you use a different Permalink structure, and to meet other requirements, add other cookies your installation may add (such as comments and WooCommerce cookies), specify cache based on response status, etc.

Not if you have the Cache Rule in place, instead of the Cache-Everything Page Rule.

3 Likes

Thank you @cbrandt - just one more question, if you have the Wordpress APO plugin running (which I do) does that negate the need to setup Cache Rules like in your post?

Yes, it does.

With APO, you should disable both the Cache Everything Page Rule and the suggested Cache Rule.

1 Like

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