Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

X-Cache Header Explanation

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

like image 786
Pigol Avatar asked Jun 12 '10 04:06

Pigol


People also ask

What does Cache-Control header do?

What is the Cache-Control Header. Cache-control is an HTTP header used to specify browser caching policies in both client requests and server responses. Policies include how a resource is cached, where it's cached and its maximum age before expiring (i.e., time to live).

What is X-cache status?

While "x-cache" indicates that a cached version of the page was not used, it was Fastly's servers that processed the request and ultimately retrieved the page from the origin (Pantheon) server. The "cf-cache-status" of "DYNAMIC" indicates that the file is not eligible for caching by Cloudflare.

Why X-cache is miss from?

After an object is requested through CloudFront, the object is cached only in the edge location that received the request. If a subsequent request is made to another edge location, the other edge location won't have a cached version of the object. This scenario returns an "X-Cache:Miss from CloudFront" response.

What is X served by?

X-Served-By indicates the shield and edge servers that were queried for the request. The shield POP appears first in the sequence and the edge POP appears second. X-Cache indicates whether the request was a HIT or a MISS for the data center.


2 Answers

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.

like image 132
Iurii Vasylenko Avatar answered Oct 22 '22 16:10

Iurii Vasylenko


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:

  • X-Cache and X-Cache-Lookup Headers
  • Understanding cache HIT and MISS headers with shielded services
like image 30
Ugnes Avatar answered Oct 22 '22 17:10

Ugnes