Reputation: 39916
I have a controller that delivers some response and I am trying to set Cache as shown below,
if(string.Equals( Request.Query["cached"] , "true", CultureInfo.IgnoreCase)){
Response.Cache.SetCacheability(HttpCacheability.Private);
Response.Cache.SetMaxAge(TimeSpan.FromDays(1));
Response.Cache.VaryByHeaders["Cookie"] = true;
}
When I see the response in Chrome, I see the header,
Cache-Control: private, max-age=86400
Vary: Accept-Encoding
Vary header is probably a default, and it is changing.
I do not want to use OutputCache because cache is enabled only for querystring parameter cached=true. When I was using ASP.NET MVC 4, I used to see response
Vary:*
And now I have upgraded my project to ASP.NET MVC 5, but its no longer working. I only want response to be cached at browser (client) based on login and cookies.
Upvotes: 1
Views: 1570
Reputation: 9854
Since december 2013 you may be able to activate IIS dynamic compression without compromising vary header. Depending on your OS version, you may need to apply a hotfix.
See following kb for the hotfix. http://support.microsoft.com/kb/2877816
This information was founded on https://stackoverflow.com/a/11156510/1178314
Upvotes: 1
Reputation: 39916
<configuration>
<system.webServer>
<urlCompression
doStaticCompression="true"
doDynamicCompression="false" />
</system.webServer>
</configuration>
Dynamic compression strips off all Vary headers, turning it off makes Vary appear correctly. But now I am dealing with how to enable Gzip for most of our requests, as there is no way to enable dynamic compression without compromising Vary header.
Upvotes: 0