I've set the OutputCache to include 'VaryByContentEncodings="gzip"' in my ASP.net ASPX page. I want the page to serve different css files, a gzipped if the browser support it and the regular non compressed if the browser doesn't support compression.
Example:
<%@ OutputCache Duration="320" VaryByParam="none" VaryByContentEncodings="gzip" %>
When I run the code I get the following error:
The 'varybycontentencodings' attribute is not supported by the 'outputcache' directive in a page.
I don't know what's the problem and why it doesn't work. Second, do you think that by serving different gzip/non-compressed CSS I'm doing the right thing. Just note that the files are served from Amazon S3, so I can't rely on IIS or .NET engine to return the compressed files automatically. That's why I want to serve to separate cached version of the page.
In this it seems to be ok, but it doesn't work (using ASP.NET 4.5):
http://msdn.microsoft.com/en-us/library/system.web.httpcachevarybycontentencodings.aspx
Help would be greatly appreciated.
Funny mistake, I've just forgot to put the Location attribute and therefore I've got an error. However, Microsoft put this code on their website, and that lead me to think that this code should work AS IS.
http://msdn.microsoft.com/en-us/library/system.web.httpcachepolicy.varybycontentencodings.aspx
VaryByContentEncodings is introduced in the .NET Framework version 3.5.
HttpCachePolicy.VaryByContentEncodings Property
I just had exactly the same problem. The problem is - Visual Studio intellisense suggests you an incorrect attribute name. The correct one, is "VaryByContentEncoding" - withough the "s" in the end.
Correct:
<%@ OutputCache ... VaryByContentEncoding="gzip" %>
Incorrect:
<%@ OutputCache ... VaryByContentEncodings="gzip" %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With