[wp-trac] [WordPress Trac] #39861: WP REST API and Caching Issue
WordPress Trac
noreply at wordpress.org
Mon Feb 13 16:32:52 UTC 2017
#39861: WP REST API and Caching Issue
--------------------------+-----------------------------
Reporter: sckmkny | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 4.7.2
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
It appears that the current implementation of the WP REST API uses the
following cache control header:
cache-control:no-cache, must-revalidate, max-age=0
The problem is that some providers, e.g., SiteGround, also tack on a bogus
last modified header:
last-modified:Thu, 01 Jan 1970 00:00:00 GMT
This combination causes the browser to add a "if-modified-since" header to
subsequent API call and resulting with a 304 response (in this case NGINX
at SiteGround). At the point, you continually get stale results from the
API.
The fix is to also add a "no-store" to the API response.
Cache-Control: no-cache, no-store, must-revalidate
For reference:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39861>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list