Using Cloudflare Cache Everything with WP Rocket

This article contains information about the most common problems when using Cloudflare's Cache Everything feature, and how to solve them.

In this Article

Admin bar is cached

This is a cosmetic issue only, not a security issue. Even if the WordPress Admin bar is cached and visible to the site visitors, they won’t be able to access your admin. If they click any link they will be required to login.

When you enable Cache Everything in Cloudflare's Page Rules, it doesn't distinguish between logged in and logged out users. This means that if you view the site while logged in, it will cache that version and show it to all users. 

Note: This is not caused by WP Rocket or has any relationship with our plugin; the admin bar is cached by Cloudflare Cache Everything

You can verify if this is the issue by turning off the  Cache Everything Page Rule in Cloudflare and testing again. From the Page Rules tab, you can do it as shown below:

If this helps, you should delete that page rule.

The only way real way around this is if you have a Business plan with Cloudflare and can use the bypass based on cookie feature. 

If you want to use Cache Everything, don't have a business plan and don't want the admin bar cached, you'll have to prevent the admin bar from being displayed on the front end of your site.

You have two options to prevent this from WordPress side: 

  1.  From the Users > Your Profile page as shown here, uncheck the “Show toolbar when viewing the site” box to prevent the admin bar from being displayed on the front end of the site, in order to avoid the admin bar to be cached
  2. You can use this function to hide the admin bar:

    add_filter( 'show_admin_bar', function( $show ) {
    	if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
    		return false;
    	}
    	return $show;
    } );
    	

     Show_admin_bar will hide the admin bar in the frontend area of your website. Please check this doc to find how to add code snippets

You can find more info, here: https://community.cloudflare.com/t/cache-everything-with-wordpress/556

Cache Everything isn't working

The browser cache rules set by WP Rocket in the htaccess file may be preventing Cache Everything from taking effect. Use the Edge TTL setting in Cloudflare to resolve this. 

Cache purging

When WP Rocket detects that Cache Everything is enabled for your site, the purging of the Cloudflare cache will be automatically sync-ed with the purging of the WP Rocket cache.

If you use Cloudflare's Page rules, this synchronization works with either the Cloudflare Add-on or the official Cloudflare plugin.

If you use Cloudflare's Cache rules, you must use the official Cloudflare plugin.

Note: The automatic cache purging for Cloudflare Cache Everything won't be triggered when Cache Lifespan runs the cache clearing for expired cache files.

Getting mobile version for desktop or the opposite

Cloudflare cache everything is not able to cache by device type. It will cache the first request of the page and keep serving it to all following visits.

Caching by device type is available only on their Automatic Platform Optimizations (APO), and Enterprise paid plan.

If your theme requires having seperate cache for mobile devices, you should turn off Cloudflare cache everything or subscribe to their APO service.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.