0

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.

1 Answer 1

1

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.

2
  • Is there a way to add a custom HTTP headers to all POST calls ? Nov 11, 2011 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. Nov 12, 2011 at 9:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .