views:

483

answers:

1

I'm using a technique similar to Rick Strahls example, but have notcied using google's speed tracer that

Resource Caching : @10.88s - The following resources specify a "Vary" header that disables caching in most versions of Internet Explorer. Fix or remove the "Vary" header for the following resources: ...

The question is Which versions of internet explorer? If I include a way of only outputting Vary for all browsers except early version of internet explorer, will this get resolved?

If AllowsCacheingOnVaryHeader() Then
  Response.AppendHeader("Vary", "Content-Encoding")
  Response.AppendHeader("Vary", "Accept-Encoding")
End If

In the function "AllowsCacheingOnVaryHeader()" - what exactly should I be checking for? All version of IE prior to 7, 8 or 9?

+3  A: 

See EricLaw's for the background on this.

Response.AppendHeader("Vary", "Accept-Encoding")

Should be OK. An up-to-date IE6 should ignore Vary: Accept-Encoding. I believe older IE6 SPs didn't.

Response.AppendHeader("Vary", "Content-Encoding")

I'm not sure what that's for. Content-Encoding is a response header not (typically) a request header so how can you Vary on it? It will certainly trip IE up, can you simply remove that and be done with it?

To answer the question: no, IE7 is still just as broken as IE6 re Vary, as it's using the same underlying wininet code. I haven't tried it but I expect IE8 is the same. IE7 does behave less badly when an ETag is supplied (it revalidates the resource instead of fully refetching it), but the basic bug is unaltered.

bobince
As Rick mentions in his blog article - vary by Content-Encoding "// Allow proxy servers to cache encoded and unencoded versions separately".
digiguru
Reading the article I guess I should 1) Only add Vary Accept-Encoding tags only in IE6(sp2) and above. 2) Include ETag in the header, and match If-None-Match to the ETag. 3) Include Vary for Content-Encoding in all browsers that are not IE6 or 7.
digiguru
It's `Vary: Accept-Encoding` that affects the proxy servers, though. `Content-Encoding` is the header that appears in a compressed *response*, but it's *request* headers that `Vary` concerns itself with. `Content-Encoding` *could* theoretically appear in a request, but only if the request itself were compressed, and I'm not aware of any browser that actually does that (or for that matter any server that supports it). So all it would actually do is trip up IE. I think the code in the blog is a typo, it should be `Accept-Encoding`.
bobince
Personally I have no trouble with just setting `Vary: Accept-Encoding` on all potentially-compressible responses; this may have been a problem with the old (pre-SV1, is it?) IE6s, but they're pretty rare now. I wouldn't try to do it by sniffing User-Agent because that would just add more Vary-ability; proxies would prefer to cache the non-Variable uncompressed version, which isn't ideal.
bobince