3

I'm experiencing a problem when using Sitecore MVC 3 rendering with GZip content compression.

I followed the blog post of John West, how to enable MVC in Sitecore.

Until now it works perfectly, the pages are rendered. But if I run the page on IIS and enable content compression (gzip), the page doesn't load. I get a "Content Encoding Error" in Firefox. Other browser display various error messages.

Has somebody experienced similar issues? Do you have any idea what the problem may be? Where should I start checking? I have to use compression on the pages.

We are using Sitecore 6, Update 5: "Sitecore 6.6.0 rev. 130404" Could this be a Sitecore bug?

EDIT 1: I am also running ASP.NET WebForms on the Sitecore instance and it works fine also with gzip compression.

EDIT 2: I have 'dynamicCompressionBeforeCache' enabled. My web.config related to gzip config:

<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
  <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
  <dynamicTypes>
    <add mimeType="text/*" enabled="true" />
    <add mimeType="message/*" enabled="true" />
    <add mimeType="application/javascript" enabled="true" />
    <add mimeType="*/*" enabled="false" />
  </dynamicTypes>
  <staticTypes>
    <add mimeType="text/*" enabled="true" />
    <add mimeType="message/*" enabled="true" />
    <add mimeType="application/javascript" enabled="true" />
    <add mimeType="*/*" enabled="false" />
  </staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true" dynamicCompressionBeforeCache="true" />
Tamas Molnar
  • 797
  • 2
  • 9
  • 25

2 Answers2

5

Sitecore confirmed that they can reproduce the issue. When setting dynamicCompressionBeforeCache="true", the encoding does not work correctly for some reason.

One solution is to remove this setting. After applying dynamicCompressionBeforeCache="false" it works fine.

Tamas Molnar
  • 797
  • 2
  • 9
  • 25
  • Did you ever get MVC compression to work? I've hit the same issue. – Jay S May 16 '15 at 08:03
  • 1
    Yes, compression works generally fine now, but I had to set the setting to false: dynamicCompressionBeforeCache="false" – Tamas Molnar May 18 '15 at 07:01
  • I was having a problem, where the packages that I created with Sitecore were created as corrupt if I had Gzip enabled. But adding the dynamicCompressionBeforeCache="false" to UrlCompression tag fixed my problem. – Aakash Shah Sep 21 '15 at 15:21
  • This fixed it for me - same issue Sitecore 8 MVC – jwsadler Nov 14 '15 at 00:22
2

You should probably enable gzip in your web.config

<system.webServer>
  <httpCompression directory="%SystemDrive%\inetpub\
temp\IIS Temporary Compressed Files">
    <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/>
    <dynamicTypes>
      <add mimeType="text/*" enabled="true"/>
      <add mimeType="message/*" enabled="true"/>
      <add mimeType="application/javascript" enabled="true"/>
      <add mimeType="*/*" enabled="false"/>
    </dynamicTypes>
    <staticTypes>
      <add mimeType="text/*" enabled="true"/>
      <add mimeType="message/*" enabled="true"/>
      <add mimeType="application/javascript" enabled="true"/>
      <add mimeType="*/*" enabled="false"/>
    </staticTypes>
  </httpCompression>
  <urlCompression doStaticCompression="true" doDynamicCompression="true"/>
</system.webServer>

There are a few more tricks here Setting the gzip compression in asp.net

Community
  • 1
  • 1
Eric Herlitz
  • 25,354
  • 27
  • 113
  • 157
  • Thanks for the answer! I have already "urlCompression" element in web.config. I tried adding the httpcompression part but nothing has changed. WebForms pages work fine and get compressed correctly by the way. I didn't find anything else at the link you provided. – Tamas Molnar Jul 23 '13 at 08:32