Rectangle 27 0

caching What is the meaning of the HTTP header Vary:*?


Effectively this tells the cache not to cache the response. That is the meaning of "subsequent requests on that resource can only be properly interpreted by the origin server". The cache must forward these requests to the origin server.

Humm... it does make sense now. OutputCacheAttribute is just a wrapper for the ASP.NET WebForms cache API. ASP.NET WebForms is based on POST calls (postbacks), so the response always vary by parameters in the POST, that are outside of the HTTP headers and the URL. That is the reason. Thanks a million, you saved me a headache :D

I have started a new question related with Vary, could you tell me if what I said makes sense? thanks : stackoverflow.com/questions/7635466/

I still don't see the point of that header. Why should I use it rather than no-cache or no-store? Why in the world would asp.net send this header together with cache instructions?

If Vary:* is passed without Content-Location, which wasn't a part of the original question, what happens - does the cache always miss? This answer doesn't quite answer the original question here.

Vary is not just for caches. It documents the content negotiation selection process. removing Vary and making the response not-public cacheable would hide the fact that negotiation took place. This would hide the fact that the request URI identifies a negotiated resource, which might be of interest to some intermediary or client.

Vary:* tells caches that the response cannot be cached for requests to /foo. But because of the Content-Location header, caches can still store the response for requests to /foo.html.

Note