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

Cache clearing between WP Rocket and Cloudflare APO will be synchronized as follows:

Full cache clearing

The APO cache for the whole site will be automatically cleared when WP Rocket's full cache clearing happens. The cache for JavaScript and CSS files will be cleared from Cloudflare's servers as well. As a reference please see scenarios when the whole cache is cleared.

In addition to the above scenarios, APO's cache will be cleared upon WP Rocket deactivation to reflect the WP Rocket status on APO's side.

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.

Notes: 

  • The automatic cache purging for Cloudflare APO Cache won't be triggered when Cache Lifespan runs the cache clearing for expired cache files.
  • The cache clearing synchronization will also purge Cache Everything.

Using Cloudflare APO with Preload

WP Rocket's Preload cache option can cache files and work along with APO. However, there may be problems if the APO cache becomes unsynchronized. You can find more information here.

Additionally, pages that were preloaded by WP Rocket won't have the  Cf-Edge-Cache header. This header is added by the Cloudflare plugin using PHP, therefore, this won't work on pages that were cached by the Preload first. There are no reported issues caused by this behavior.

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:

In the above cases, the following admin notice will be displayed:

dynamic cookie apo notice

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

Cloudflare APO is not compatible with WP Rocket's Cloudflare add-on. This means WP Rocket and Cloudflare's cache layers will not be synced.

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:

  1. In WP Rocket, enable and set the Cloudflare add-on
  2. Activate the Optimal Settings option in this add-on (recommended)
  3. From the WordPress settings: UsersYour 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
  4. 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.

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