Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vary header when content is not gzip:ed on IIS 7 as origin for CDN

Tags:

iis

gzip

cdn

I'm trying to set up my IIS server as an origin server for a CDN. I have solved some issues already for example that IIS doesn't give gziped content to proxies (if they have the via header) and also that frequentHitThreshold problem.

My CDN supplier pointed out that another problem with IIS is that it doesn't return a "Vary" header if the client doesn't request the content gziped. According to them the problem is that if for some reason the first client that request the content doesn't want the content gziped the CDN then doesn't request a new version of the file since the Vary header doesn't indicate that it should return two different files depending on "Accept-Encoding".

My only solution so far is to add "Vary: Accept-Encoding" as a custom header but since IIS automatically add this vary header when gziped is requested so i end up with multiple values like "Vary: Accept-Encoding, Accept-Encoding".

Anyone have any solution to this? Or can confirm that it's a real issue.

like image 442
Olaj Avatar asked Jun 26 '12 11:06

Olaj


People also ask

Is there a way to enable gzip in the response header?

But there's no: Content-Encoding: gzip In the Response Header. In my case problem was with antivirus protection. Actually gzipping was applied but antivirus with enabled settings protect http connections (depends on concrete program), unzip response check it and after that rewrite response headers on the fly.

What is the vary Origin header for?

It's important to include the Vary: Origin header to prevent caching. The header indicates that the response is in some way dependent on the origin and should therefore not be served from cache for any other origin.

What is the use of vary header in a response?

This response header is used by the server to indicate the headers it used when selecting a representation of a resource in a content negotiation algorithm. The Vary header should be set on a 304 Not Modified response exactly like it would have been set on an equivalent 200 OK response. Vary: * Vary: <header-name>, <header-name>, ...

What is the vary header on a 304 not modified response?

This response header is used by the server to indicate the headers it used when selecting a representation of a resource in a content negotiation algorithm. The Vary header should be set on a 304 Not Modified response exactly like it would have been set on an equivalent 200 OK response.


2 Answers

This is a real issue. IIS gzip module overwrites existing Vary headers. Please vote on this MS Connect issue. Related article here.

like image 164
Dmitry Avatar answered Sep 28 '22 11:09

Dmitry


This issue is now addressed by an official patch to IIS. To download and further info, visit http://support.microsoft.com/kb/2877816

Erez Benari, IIS PM

like image 38
Erez Benari Avatar answered Sep 28 '22 12:09

Erez Benari