Cloudflare and caching

Cloudflare and other caching plugins can sometimes aggressively cache pages. This means when you update Search Regex and then try to access it, the page has been cached and contains old data. Search Regex will detect this and you may see a message like this:

What this means is that WordPress is trying to load the new version, but what is actually being loaded from Cloudflare’s cache is an older version. This doesn’t match up and rather than continue on and potentially cause problems, Search Regex shows an error.

Search Regex tries to prevent this from happening by ‘busting’ the cache, but Cloudflare removes this, and so the problem occurs.

Alright, but what do I do?

First you’ll need to know the URL for your Search Regex plugin. The above error message will show this information as the JavaScript value and it will look something like:

Then on Cloudflare:

  • From the ‘Caching’ option, select ‘Purge individual files’ and enter the above URL
  • Under ‘Page Rules’ create a rule for the above URL and set ‘disable railgun’, ‘disable performance’, and set the cache level to ‘bypass’

This will clear your Cloudflare cache and will stop Cloudflare caching Search Regex in the future.

Invalid REST cookie nonce

If you see a message about rest_cookie_invalid_nonce and you are using Cloudflare then it’s likely that your WordPress REST API is being cached.

You will need to prevent Cloudflare from caching /wp-json/.