AI OnAI Off
Hi Ayo, out of curiosity why are you trying to implement gzip compression yourself? Why not use the IIS feature, you must have a reason why you don't want to use that?
You are not checking does the caller support gzip (request header Accept-Encoding).
And then when requesting for static files (like css, js, images, etc) those are handled by IIS and never hit asp.net (unless you remove the mappings / register your own handlers). I'm assuming your /Content/css/styles.css is actually a file on the disk and not stored to Episerver media library.
So if the styles.css is actually a static resource then check that the file encoding is the same encoding as the encoding set in web.config (default is UTF-8, defined in the globalization element).
I have a MVC application that is using GZIP to compress the content before it gets to the client.
This is working, however intermittently CSS files are being returned as symbols:
[![enter image description here][1]][1]
I had a few issues getting GZIP to work but in the end I added some code to my Application_BeginRequest method to force everything to get GZIPed, the web application is running on a Content Management System, so I am avoiding any CMS related paths:
After a big of googling, I think this may have something to do with staticCompressionIgnoreHitFrequency, though I don't fully understand why.
The symbols seem to show up with I clear the cache and request the CSS file again.
can I set staticCompressionIgnoreHitFrequency in the C# code some how?
Can anyone come up with an explanation of whats going on here?
**UPDATE:**
This seems to happen only when I do hard refresh.
So I put a break point in visual studio to see if there was a difference between the request with out a hard refresh and the request with a hard refresh, and the only diffrence I could see is that the header If-Modified-Since is always null if I do a hard refesh, so I have put in an extra if statement like this:
This seems to solve the problem, but I'm not sure if this is just a work around.... would really appreciate if someone can shed some light on this?