Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

Regards.

share|improve this question
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.