1

I'm using ASP.NET MVC's built in bundling of both our CSS and javascript.

This bundles the CSS into a bundle called

/Content/allcss?v=b2tuMEFw5RyKcq1cIwQCy0z5sJ_hUCzkzORKUQzsdow1

and the javascript into

/bundles/identity?v=h8j2kTCIC9kJAFTNr9X5evhiqPEF4I0uEN0GydPQyxY1

To get gzip to work in IIS 7.5 locally, I didn't need to change my web.config at all - all I needed to do was enable static compression and dynamic compression on my website in IIS Manager. With that done I can see the response headers for the JS bundle:

/bundles/identity?v=h8j2kTCIC9kJAFTNr9X5evhiqPEF4I0uEN0GydPQyxY1

Content-Type: text/javascript; charset=utf-8

Content-Encoding: gzip

When this is deployed to our Azure A2 cloud service (web role), gzip is not working on the JS bundle. It IS working on the CSS bundle. I have remote desktopped to the Azure Web Role instances and can see that static and dynamic compression are enabled in IIS. However, the js bundle still doesn't have gzip compression. The response has the same Content-Type but no Content-Encoding header.

Content-Type: text/javascript; charset=utf-8

How can I enable gzip compression on the javascript bundle in an Azure Web role?

Update: I followed this post to enable Failed Request Tracing and found that IIS is logging

DYNAMIC_COMPRESSION_NOT_SUCCESS Reason NO_COMPRESSION_PROXY

Community
  • 1
  • 1
Matt Frear
  • 52,283
  • 12
  • 78
  • 86

1 Answers1

3

I had to change %windir%\System32\inetsrv\config\applicationHost.config and add noCompressionForProxies="false"

<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" noCompressionForProxies="false">

but it's better to change that setting as part of our deployment process like so:

%windir%\system32\inetsrv\AppCmd.exe set config -section:httpCompression /noCompressionForProxies:false

And, FWIW, if possible disable your cloud services in other regions and scale back your instance count to 1 when you're trying to debug this sort of thing. I had 2 instances in 2 regions which was causing confusion when it came to updating web.config and applicationhost.config files across 4 VMs.

Matt Frear
  • 52,283
  • 12
  • 78
  • 86