Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Alastair Todd 44 posts 142 karma points
    Feb 14, 2016 @ 13:55
    Alastair Todd
    0

    Cannot get API responses to gzip

    How do we get Umbraco to honour gzip response directives?

    Nothing I do seems to make a difference.

    IIS 10 by default enables it. The is my applicationHost.config snippet (its the default in IIS10):

    <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
                <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
                <staticTypes>
                    <add mimeType="text/*" enabled="true" />
                    <add mimeType="message/*" enabled="true" />
                    <add mimeType="application/javascript" enabled="true" />
                    <add mimeType="application/atom+xml" enabled="true" />
                    <add mimeType="application/xaml+xml" enabled="true" />
                    <add mimeType="image/svg+xml" enabled="true" />
                    <add mimeType="*/*" enabled="false" />
                </staticTypes>
                <dynamicTypes>
                    <add mimeType="text/*" enabled="true" />
                    <add mimeType="message/*" enabled="true" />
                    <add mimeType="application/x-javascript" enabled="true" />
                    <add mimeType="application/javascript" enabled="true" />
            <add mimeType="application/json" enabled="true" /> 
                    <add mimeType="*/*" enabled="false" />
                </dynamicTypes>
            </httpCompression>
    

    Anyway another site I have running off same IIS is gzipping correctly (which proves dynamic content compression is enabled in Windows). Also the main site assets are coming down gzipped - just custom api content (application/json) is not.

    I have tried various permutations of the Umbraco settings in web.config to no avail:

    Any ideas anyone please?

    <location path="umbraco">
        <system.webServer>
          <urlCompression doStaticCompression="false" doDynamicCompression="false" dynamicCompressionBeforeCache="false" />
        </system.webServer>
      </location>
      <location path="App_Plugins">
        <system.webServer>
          <urlCompression doStaticCompression="false" doDynamicCompression="false" dynamicCompressionBeforeCache="false" />
        </system.webServer>
      </location>
        <location path="umbraco/api">
        <system.webServer>
          <urlCompression doStaticCompression="true" doDynamicCompression="true" dynamicCompressionBeforeCache="true" />
        </system.webServer>
      </location>
    
  • Alastair Todd 44 posts 142 karma points
    Feb 14, 2016 @ 18:09
    Alastair Todd
    0

    Found an answer to this, so will leave it here for future reference.

    Something to consider when enabling compression in IIS via the applicationHost.config file.

    Use the IIS config manager to make the changes or notepad.exe to edit the file. I was using Notepad++ and even though the file was saving, it actually was not.

    Something to do with 32/64bit environments, configs and the programs that edit them. Ruined my afternoon!!

  • Gunnar Már Óttarsson 4 posts 72 karma points
    Jul 22, 2017 @ 19:03
    Gunnar Már Óttarsson
    0

    Seems like it might be a good idea to have

    But maybe a better question is why they chose to override the defaults for the backoffice. Seems like a lot of content there like angular views and controllers would be better suited as compressed by default

  • Rasmus Lynggaard 110 posts 297 karma points
    Dec 20, 2018 @ 13:33
    Rasmus Lynggaard
    0

    Did you get this to work. Can't get compression to work for the umbraco/api location, unless I remove the location path="umbraco" from web.config

  • aman 5 posts 75 karma points
    Apr 30, 2019 @ 23:28
    aman
    0

    I believe I got it working by adding an additional location element for the API pathway. This keeps compression off for the backoffice, but enables it for your custom API controllers.

    <location path="umbraco">
      <system.webServer>
        <urlCompression doStaticCompression="false" doDynamicCompression="false" dynamicCompressionBeforeCache="false" />
      </system.webServer>
    </location>
    <location path="umbraco/api">
      <system.webServer>
        <urlCompression doStaticCompression="false" doDynamicCompression="true" dynamicCompressionBeforeCache="false" />
      </system.webServer>
    </location>
    

    Oddly enough, if I set dynamicCompressionBeforeCache to true for the umbraco/api path, gzip compression does not happen.

    I do wish some Umbraco guru would chime in on this though and confirm if this is a good enough approach. Seems like a lot of people run into this issue, but there's not a whole lot in the way of a solution.

Please Sign in or register to post replies

Write your reply to:

Draft