Knowledge Base

CDN REST API Caching: Success message, but when reloading the page I do not see a new item

You have created an item, e.g. a folder or a content blocker and get a success message, but after reloading your browser the item has disappeared again? This problem can occur with website that use a Content Delivery Network (CDN) like CloudFlare, StackPath, Akamai and have configured them aggressively.

All of our WordPress products use a modern technology that was introduced with WordPress 4.7: WP REST API (you can learn more about it in the WordPress REST API Handbook). In most cases, there are no issues with WP REST API and a CDN, but if you have a special configuration, the fetched data can be “out of date”. If you are technically skilled and take a look at your network requests (in your browser F12 > tab “Network”), you will see if your CDN handles requests for the WP REST API:

REST API request cached via Cloudflare

This is fine, but some configurations can cause data delivered via the REST API to be cached by the CDN and not updated when a change was made.

Solution: Disable caching for REST API

Do not panic! This article can get very technical. If you get confused yourself, it may be helpful to contact your technical contact and/or hosting provider.

The WP REST API should not be cached in most cases, as it mostly delivers dynamic data. Therefore, you should disable caching for them. If your domain is example.com, you should disable caching for https://example.com/wp-json/* (all routes of the REST API).

How this works in your case depends on your CDN. Read the help articles of your CDN:

Why don’t other plugins have this problem?

Many WordPress plugins do not yet use the modern of WP REST API. They still use the old admin-ajax.php mechanism, which is described as deprecated by the WordPress Core. This old mechanism is treated differently by CDNs.

WordPress Plugins by devowl.io

Find helpful articles

Topics