Search code examples
c#compressiongzipowinkatana

OWIN GZip Compression prevented by User-Agent


I have an OWIN/Katana self hosted web server that serves static files. I am attempting to gzip the response and hitting an issue where User-Agents added by either IE or Chrome are preventing this from happening.

In Fiddler, using header Accept-Encoding: gzip, deflate, sdch I correctly get Content-Encoding: deflate

If I add:

User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36

or

User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko

Then the response no longer has content encoding.

I have tried using custom middleware and Owin.Compression https://github.com/Thorium/Owin.Compression

               appBuilder.UseCompressionModule();
               //appBuilder.Use<GZipMiddleware>();

               appBuilder.UseStaticFiles(
                   new StaticFileOptions
                   {
                       RequestPath = new PathString(ApplicationPath),
                       FileSystem = new PhysicalFileSystem("app")
                   });

Solution

  • Solved the issue.

    My Antivirus (ESET) was decompressing the responses and removing the headers in order to scan the content. As this was a locked down work machine and I couldn't adjust the settings, I was able to confirm using a VM and continue testing.