Page cache
The VIP Platform’s page cache is the first level of caching that each request encounters for both WordPress and Node.js environments.
VIP’s global network of edge cache server locations serves a copy of the full page response generated by a site (usually from memory). Most of a site’s traffic can be served from the edge location closest to the user making the request, without ever hitting a line of PHP. This caching strategy provides low latency and very high site performance.
Insights into the page cache hit rate for HTTP requests that are made to an environment can be reviewed in the Insights & Metrics panel of the VIP Dashboard.
Default cache responses
By default, all requests made with HEAD or GET HTTP request methods are cached.
The following responses are cached by default for WordPress and Node.js environments:
- Responses with an HTTP Status Code of
200 OK, including WordPress posts, pages, archives, the home page,/graphql, etc., are cached at the edge cache server locations for 30 minutes by default.- For browser cache control purposes these responses are sent with a
cache-controlHTTP response header ofmax-age=300, must-revalidateby default. - Changes made to WordPress site content will automatically notify the edge caches of the new data and trigger a purge of cached versions of that content. The next incoming request for that content will be sent to origin and the response will be served then stored in cache.
- A stale response could be served by the page cache up to 12 hours for a cached object outside of a resource’s set
max-agewhile the page cache fetches an updated response from the origin to serve for future requests.
- For browser cache control purposes these responses are sent with a
- Redirects with a
301 Moved PermanentlyHTTP status are cached for 30 minutes. - Responses with
302 Foundand307 Temporary RedirectHTTP status are cached for 1 minute. - Responses with
404 Not FoundHTTP status are cached for 10 seconds. - Responses with
410 GoneHTTP status are cached for 1 minute. - All WordPress REST API responses are cached for 1 minute via code in the mu-plugins.
HTTP status code responses that are not cached
The following responses are not cached by default for WordPress and Node.js environments:
206 Partial Content400 Bad Request416 Range Not Satisfiable429 Too Many Requests431 Request Header Fields Too Large- All
5xxresponses
Note
Because the rendered HTML for a request is cached for up to 30 minutes, the references to updated static asset files could be up to 30 minutes out of date. The version number on an enqueued asset must be updated to prompt VIP to use the new concatenated versions when JS or CSS has been edited.
Cache bypass or prevention
WordPress and Node.js environments on the VIP Platform allow the following default cache bypass behaviors in the page cache:
- The presence of certain cookies will cause the page cache to be bypassed.
- All requests sent with an HTTP
Authorizationheader will bypass the cache. - All requests made with
POST,PUT, orDELETEHTTP request methods will bypass the cache. - Requests made to WordPress environments by logged-in users bypass the page cache entirely.
- Logged-in users, commenters, requests to modify state (such as
POSTrequests), and requests for pages not actively cached at the edge will be routed to the WordPress site’s origin servers, which run the site’s code and database. no-cacheheaders are respected vianocache_headers(). However, useno-cacheheaders cautiously as they will result in a poor cache hit rate.- By default, responses with
401 Unauthorizedand431 Request Header Fields Too LargeHTTP status codes are not cached. - All requests made to an environment with Basic Authentication enabled will bypass the cache.
Automatic cache clearing for WordPress content
Updating or publishing a WordPress page or a post of any kind (built-in post or custom post type) will clear the following caches by default in the page cache:
- The single post/page URL
- The comments feed URL for that post/page
- The term archive URL for all terms associated with the post
- The term archive feed URL for all terms associated with the post
- The home page
- The page for posts (if it is set)
- The RSS feed
When a term is created, updated, or deleted in WordPress, the following caches are cleared by default:
- The term archive URL for all terms associated with the post
- The term archive feed URL for all terms associated with the post
Switching a theme will purge the entire page cache of the WordPress site.
Customizing cache clearing behavior
Custom NGINX rules cannot be added to modify cache clearing behavior for a WordPress or Node.js application. Instead, the VIP Cache API should be leveraged to customize cache clearing behavior.
Customization options include:
- Automatically purging the cache for a url or a custom API endpoint when a change is made in the WordPress Admin dashboard.
- Clearing the cache for a specific URL, post, or term.
- Filtering the URLs that are queued for cache clearance.
Review the cache behavior of a request
The x-cache HTTP response header provides the type of interaction the response had with the page cache. Use a browser’s developer tools to review more information about the cache behavior of a request in the following HTTP response headers:
HITindicates that the response is from cache.MISSindicates that the requested content was not found in cache and the response is from origin.BYPASSindicates that cache was bypassed and the response is from the origin.STALEindicates that a stale cached response was served while the page cache fetches an updated response from the origin to serve to future requests.UPDATINGindicates that the cache is still in the process of updating stale content with a response from origin.
Default behavior of some HTTP headers
- The
s-maxageresponse directive is honored by the page cache. If aCache-ControlHTTP header contains ans-maxageresponse directive, thes-maxagevalue will take precedence overmax-age. - A unique ID value is assigned to every incoming request to the edge and stored in the
X-Request-IdHTTP header. This value is recorded and retrievable in the HTTP Request Log Shippingrequest_idfield for an environment. In PHP the HTTP header request ID value is retrievable with:$_SERVER['HTTP_X_REQUEST_ID'] - By design, incoming requests to the origin that use the HTTP
HEADmethod are transformed intoGETrequests by the page cache. As a result, the value of$_SERVER['REQUEST_METHOD']for those requests will beGET. For this reason, avoid logic at the origin that depends on detectingHEADrequests. - Responses are automatically segmented into User-Agent class buckets:
desktop,smart,tablet, anddumb.
Last updated: July 16, 2024

