Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have enabled in my Web.config the GZIP compression, and I'm glad that it automatically adds the HTTP header "Vary: Accept-Encoding".

The problem is that IIS is overwriting the "Vary:*" that ASP.NET returns by default.

The issue is that in POST calls, the "Vary" header has to be "*", because it means the response depends on things that are not in the URL or the HTTP headers... as far as I know. A POST call with a "Vary:Accept-Encoding" could be wrongly cached, am I right?

What I want to do is tell IIS to respect the previous "Vary" header if any.


share|improve this question
up vote 1 down vote accepted

A POST request should never be cached unless it's explicitly allowed to be by either a Cache-Control or Expires header in the response. The Vary header can be used by a proxy server to optimize the decision if it can return a cached response but that's only if the response was allowed to be cached in the first place. So if you make sure the response of your POST request is not allowed to be cached, the Vary header will/should not make it cacheable whatever it is set to.

share|improve this answer
Is there a way to add a custom HTTP headers to all POST calls ? – NullOrEmpty Nov 11 '11 at 16:29
You can control everything you want through Response.Cache which is of type HttpCachePolicy. Here is also a nice blog post on creating a custom action filter for controlling cache headers and gzip compression. – Marco Miltenburg Nov 12 '11 at 9:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.