Using Cloudflare APO with WP Rocket
From the 3.14 version, WP Rocket is compatible with Cloudflare APO, meaning that the cache clearing between WP Rocket and Cloudflare APO will be synchronized.
Note: In order to work, this compatibility requires the Cloudflare's official plugin to be activated, and the Cloudflare account to be fully authenticated in that plugin.
When Cloudflare's official plugin is active, Cloudflare's Add-on will be dimmed, and cache clearing will be handled automatically.
If Cloudflare's official plugin is not installed or is not active, Cloudflare's Add-on can still be used to synchronize other Cloudflare features except for synchronizing cache clearing. This configuration is aimed at Cloudflare users that are not using APO, see more information here.
Cache clearing between WP Rocket and Cloudflare APO will be synchronized as follows:
Full cache clearing
Please note that Clearing APO cache with the “ Purge Everything” option within Cloudflare's official plugin will not clear WP Rocket cache.
Partial cache clearing
WP Rocket clears the cache for a few specific pages in these scenarios, with APO compatibility, those specific URLs (except for date archives and term archives) will be automatically cleared from Cloudflare network as well.
Using the Purge Individual Files option in Cloudflare's official plugin will not clear WP Rocket cache for the specific purged pages.
Using Cloudflare APO compatibility with Separate cache files for mobile devices
WP Rocket's Separate cache files for mobile devices feature and Cloudflare's Cache by device type should be configured accordingly to have the same behavior when delivering cache to different device types.
So, if Separate cache files for mobile devices is enabled, Cloudflare's Cache by device type option should be enabled too. This is to make sure the mobile-specific files are served to the right type of devices and avoid the issue described here.
Also, if Cache by device type option is enabled, you should consider enabling the Separate cache files for mobile devices option, as well.
If there is a mismatch in the status of the features, the following admin notices will be displayed:
WP Rocket: You are using "Separate cache files for mobile devices". You need to activate "Cache by Device Type" setting on Cloudflare APO to serve the right version of the cache.
WP Rocket: You have "Cache by Device Type" enabled on Cloudflare APO. If you judge it necessary for the website to have a different cache on mobile and desktop, we suggest you enable our “Separate Cache Files for Mobiles Devices” to ensure the generated cache is accurate.
Cloudflare APO and query strings caching
Cloudflare APO is not compatible with the Cache Query String(s) feature.
With WP Rocket, pages using specific parameters will get the default caching, and URLs using other parameters can be cached using the Cache Query String(s) feature.
On the other hand, while Cloudflare APO can serve cache to URLs with some parameters too, it doesn't allow serving cache to URLs with custom parameters, more information can be found here.
Please note, if Cache Everything is used along with APO, any URL using query strings added to the Cache Query String(s) box will be cached as expected. If Cache Everything is not used, APO won't cache URLs with cached query strings.
Cloudflare APO and dynamic/mandatory cookies
Cloudflare APO is not compatible with WP Rocket's dynamic and mandatory cookies features, because APO can't serve different cache versions based on different cookie values.
Therefore, there will be problems with the cache version served to the visitors in the following cases:
- Plugins with compatibility based on mandatory cookies or with dynamic cookies are active.
- The WP Rocket | Cache Dynamic Cookie or WP Rocket | Cache Mandatory Cookie helper plugins are active.
rocket_cache_mandatory_cookiesfilters are used for other custom implementations.
In the above cases, the following admin notice will be displayed:
WP Rocket: You are using "Dynamic Cookies Cache". Cloudflare APO is not yet compatible with that feature.
You should either disable Cloudflare APO or check with the theme/plugin requiring the use of “Dynamic Cookies Cache” developers for an alternative way to be page-cache friendly.
WP Rocket versions older than 3.14
Therefore, for websites using dynamic content, you’ll need to disable the WP Rocket Cloudflare add-on and use the official Cloudflare plugin instead.
You can still use WP Rocket but you'll need to manually clear Cloudflare's APO cache, using the official plugin, after you've changed your settings in WP Rocket.
However, if you have a static website, you can enable the Cache Everything feature in your Free Plan, as the Cloudflare APO service is similar to the Cache Everything feature. The Free plan has 3 page rules that can be used to include or exclude pages that needs to be cached or excluded.
To do so, follow these few steps:
- In WP Rocket, enable and set the Cloudflare add-on
- Activate the Optimal Settings option in this add-on (recommended)
- From the WordPress settings: Users > Your Profile page, 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.
- In your Cloudflare account, from the Page Rules tab, activate the Cache Everything feature by creating your page rules.
Remember this solution will only suite static websites.