X-Cache Header Explanation

69,029

Solution 1

CDN (Content Delivery Network) adds X-cache header to HTTP Response. X-cache:HIT means that your request was served by CDN, not origin servers. CDN is a special network designed to cache content, so that usr request served faster + to unload origin servers.

Solution 2

Prefix 'X' in X-Cache indicates that the header is not a standard HTTP Header Field. Also its meaning vary from one proxy implementation to another. A common place to find these header fields is in squid servers. Organizations and universities place proxy (squid) servers between their and outer network. This serves two purposes. One of security, and other of caching more frequent web pages (in order to limit network traffic).

X-Cache corresponds to the result, whether the proxy has served the result from cache (HIT for yes, and MISS for no)
X-Cache-Lookup represents if the proxy has a cache-able response to the request (HIT for yes and MISS for no)

Both HITs means that the client has made a cache-able request and the proxy had a cache-able response that matched, and was forwarded back to the client. In case X-Cache is MISS and X-Cache_Lookup is HIT, then the client made a request that had a cache-able response but was forced by the client to bypass the cache. This is hard refresh, which can be simulated by Ctrl + F5 or by sending headers: Pragma: no-cache (in HTTP/1.0) and Cache-Control: no-cache (HTTP/1.1)
If both are MISS(es) then the request by the client doesn't have any valid object corresponding to the request.

Some Useful Resources:

Solution 3

X-Cache "is NOT a standard HTTP header field".

Also, check out X-Cache and X-Cache-Lookup headers explained.

Solution 4

for me me this was related to fastcgi cache header existing on Nginx server block

  add_header X-Cache $upstream_cache_status;

just removing commenting this line and restart nginx the header were removed .

Share:
69,029
Zr Classic
Author by

Zr Classic

Updated on October 27, 2020

Comments

  • Zr Classic
    Zr Classic over 3 years

    I was going through the firefox local cache folder and found a lot of files containing the X-cache header. Can someone explain the purpose of this header ?

    thanks

  • Yuriy Vasylenko
    Yuriy Vasylenko about 9 years
    Furthermore, there are a bunch of "X- " headers provided by CDNs. They indicate HIT, MISS etc. You can simply install firebug plugin in firefox and request some progressive download video, probably it'll be served by cdn node, so the HOST header in response might contain smth like cdn.rt.com and there will be "X- " headers
  • Ugnes
    Ugnes over 7 years
    Also remember that cache is being maintained on different levels. This is more related to squid servers and proxy.