Introduction
You may use the following steps to add the X-Cache-Status header to all of the responses that NGINX serves to help determine what responses have served from Cache and what responses have not been served from cache.
Procedure
- Login to the server as the root user via SSH or Terminal
- Open the following file:
/etc/nginx/ea-nginx/cache.json
- Find the following line:
"x_cache_header" : false,
- Change it to:
"x_cache_header" : true,
- Run the following command to rebuild the configuration:
/scripts/ea-nginx config --global
The following are the possible values for $upstream_cache_status, which would be what is provided within the response header:
MISS – The response was not found in the cache and so was fetched from an origin server. The response might then have been cached.
BYPASS – The response was fetched from the origin server instead of served from the cache because the request matched a proxy_cache_bypass directive. The response might then have been cached.
EXPIRED – The entry in the cache has expired. The response contains fresh content from the origin server.
STALE – The content is stale because the origin server is not responding correctly, and proxy_cache_use_stale was configured.
UPDATING – The content is stale because the entry is currently being updated in response to a previous request, and proxy_cache_use_stale updating is configured.
REVALIDATED – The proxy_cache_revalidate directive was enabled and NGINX verified that the current cached content was still valid (If-Modified-Since or If-None-Match).
HIT – The response contains valid, fresh content direct from the cache.
Comments
0 comments
Article is closed for comments.