Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#51831 closed defect (bug) (duplicate)

WP REST API and Caching Issue

Reported by: mguenter's profile mguenter Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.5.3
Component: REST API Keywords:
Focuses: rest-api Cc:


A follow-up to, cause I can not change the WordPress version to 5.5.3.

Hey @joehoyle and @lukecavanagh,

I just came across this ticket because I have a similar issue. We have implemented a dashboard in a WordPress submenu page. Imagine the following scenario:

  1. Open the dashboard
  2. JavaScript is fetching data via GET from a WP REST API endpoint
  3. Click on another submenu, e.g. media library
  4. Use the back button from the browser
  5. Check the network log and you will see, that the WP REST API request got cached (200 OK (from disk cache))

Tested on Chrome, but I think this happens on all browsers.

How can this be fixed? Using the following header disallows the browsers to cache the response:

Cache-Control: no-cache, no-store, must-revalidate, max-age=0

Add no-store directive, see also and

The solution? Add the no-store cache directive. It tells the browser to really not store anything at > all. So this works, and clicking the back button in Chrome will never serve up cached content: [...]

If you fix this, you need to be careful, because the directive should probably only be added on WP REST API calls.

Change History (1)

#1 @TimothyBlynJacobs
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi @mguenter,

Please add your comment to #39861 so we can keep the discussion focussed in one place. You don't need to change the version number to report the issue.


Note: See TracTickets for help on using tickets.