Questions tagged [vary]

The Vary response header is used for indicating to browsers and other user agents which request header values to check when deciding whether to load content from a cache or to instead fetch a new response over the network.

The Vary header is defined in RFC 7231 http://httpwg.org/specs/rfc7231.html#header.vary. Its value is a list of header names. Here’s a simple example of how it works:

  1. Code running in a browser at https://origin-a.com makes a request to https://some-server.com/some/path with the request header Origin: https://origin-a.com.
  2. The https://some-server.com server sends back the response with the content from /some/path and the response header Vary: Origin.
  3. A browser receives the response and caches the content from /some/path.
  4. Code running in the browser at https://origin-b.com makes a request to https://some-server.com/some/path with the request header Origin: https://origin-b.com.
  5. The browser sees that the Origin request-header value for the code from https://origin-b.com is different from that of https://origin-a.com, so instead of using the /some/path content it cached previously, the browser fetches a new response from https://some-server.com/some/path over the network.

For more details, see the following:

40 questions
13
votes
2 answers

Multiple Vary HTTP headers or one combined?

Question: What is the best way to send Vary HTTP header when server accept gzip/deflate connections AND serve a different content for mobile clients? I see two possible variants but I cannot find any useful information whether they are correct…
WASD42
  • 2,244
  • 6
  • 25
  • 41
9
votes
2 answers

what does this configuration in apache mean?

Header append Vary User-Agent env=!dont-vary Can anyone give a detailed explanation for this?
omg
  • 123,990
  • 135
  • 275
  • 341
7
votes
2 answers

In ASP.NET, is it possible to output cache by host name? ie varybyhost or varbyhostheader?

I've got a website that has a number of host headers. The theme and data depend on the host header, and different hosts load different looking sites. So let's imagine I have a website called "Foo" that returns search results. The same code runs both…
Pure.Krome
  • 78,923
  • 102
  • 356
  • 586
6
votes
3 answers

mod_rewrite not sending Vary: Accept-Language when RewriteCond matches

I have a rewrite rule which redirects to / if no Accept-Language header is present and someone attempts to visit ?lang=en. It works fine, except for the headers returned. Vary: Accept-Language is missing from the response. RewriteCond…
Lucent
  • 1,296
  • 15
  • 22
5
votes
2 answers

HTTP Vary: Cookie vs Cache-Control: private

I am writing a web application framework. To properly support reverse proxy servers, I want to make sure that whenever the web application is accessing cookie data, pages that are sent to the user are cached only for that user. As far as I know,…
frodeborli
  • 1,087
  • 11
  • 23
4
votes
1 answer

Sitecore caching and varying

This is my first time with Sitecore caching and I haven't been able to find a good guide about how to use the various varying options in Sitecore. I want to know how each is different, how they differ in regards to what they cache and also in what…
Gabbar
  • 3,818
  • 4
  • 35
  • 71
4
votes
1 answer

PHP/Ajax "Vary: X-Requested-With" does not work for me!

i am trying to serve cacheable Content depending on whether it is an ajax request or not. Scenario: A little PHP-script "/test.php" serves some HTML-Output and sets the following Headers: Expires Wed, 23 Feb 2011 13:30:06 GMT Cache-Control …
Ilja
  • 106
  • 6
4
votes
2 answers

Does Chrome support the HTTP Vary header

Does Chrome's cache support the HTTP Vary header? For a specific url request the server responds two different html files depending if it's an ajax request or not. So I added the Vary header to X-Requested-With. I was expecting Chrome to record two…
4
votes
2 answers

Where and How to set Vary: User-Agent HTTP Header

According to Search Engine Land and many other sources, if you're designing "Dynamic Serving" mobile content for your site, you should set the HTTP header Vary: User-Agent. Is this done in the .htaccess file or somewhere else? This would be my…
NotJay
  • 3,583
  • 5
  • 34
  • 61
4
votes
2 answers

How to Vary Dot Size in dotchart() in R

I have a question on creating a dotchart using the following data: Patient ID Day Dosage of Drug (mg) 1552 1 .3 1552 7 .8 1552 14 1.2 1663 1 .2 1663 7 .7 1663 …
JohnLu
  • 41
  • 2
3
votes
1 answer

Django missing Vary:Cookie header for cached views

I've got a pretty complex webapp based on Django 1.11. Some time ago users started reporting that they are getting 'someone else's views' - memcached provided them with html cached by decorator @cache_page(xx) without distinguishing between…
Brachacz
  • 86
  • 3
2
votes
1 answer

Caching with Varnish & Varying over custom-set HTTP headers

I'm developing your standard high traffic ecommerce website and want to setup caching with Varnish. The particular thing on this setup is that the application will return different content depending on the user's particular location. So my plans…
pantulis
  • 1,615
  • 11
  • 14
2
votes
2 answers

How to ensure my CDN caches CORS requests by origin?

I currently use Akamai as a CDN for my app, which is served over multiple subdomains. I recently realized that Akamai is caching CORS requests the same, regardless of the origin from which they were requested. This of course causes clients that…
Brad Parks
  • 54,283
  • 54
  • 221
  • 287
2
votes
2 answers

Is there ever any reason to respond with "Vary: *" and "Vary: Foo" for the same resource?

Is there any reason for a HTTP server to sometimes respond with Vary: *, and sometimes with Vary: Foo, to requests for the same resource? What should a cache do, if after receiving (and caching) both responses, it then receives a request with a…
mjs
  • 57,072
  • 26
  • 82
  • 114
2
votes
0 answers

Dynamic IIS Compression Module and Vary: Accept-Encoding Header is not overwritten

When you enable dynamic content compression on a computer that is running Windows Server 2008, a Vary header is always overwritten as "Accept-Encoding.". You cannot change it by code. This hotfix http://support.microsoft.com/kb/2877816 resolves the…
1
2 3