3

i want gzip css and js file in website. and use this code in 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"/>

analyze my website with gtmetrix.com site, but get:

Compressing the following resources with gzip could reduce their transfer size by 63.4KiB (77% reduction).

Compressing http://mysite.com/ could save 30.6KiB (74% reduction).
Compressing http://mysite.com/WebResource.axd?d=TdZvTxV1RZCMol6igoEA7XxfdqcWpTRlYuCxfymg_ruU4xc1NuSqLn7bduKh3WyPwSYX0g86d6fEJ3SVBdeWi5FBnMpKfcO7aaFoqvmTo_c1&t=634970873020000000 could save 17.5KiB (80% reduction).
Compressing http://mysite.com/main.css could save 14.8KiB (80% reduction).
shahin ko
  • 253
  • 2
  • 4
  • 13

3 Answers3

1

As per this answer, the compression happens in a background process on a different thread, so it won't be available on the first request. Also, keep in mind this is not an ASP.NET feature, but an IIS feature.

There is also an answer here that shows a valid configuration.

Tip: You may also want to check into using bundling and minification.

Community
  • 1
  • 1
NightOwl888
  • 55,572
  • 24
  • 139
  • 212
0

For the dynamictypes in your web config you will also need to install the dynamic compression module in IIS else these won't do anything.

Barsonax
  • 197
  • 2
  • 12
-1

I found a code that u should use after in web.config file in your file manager:

<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>

I used it now in my website: www.irpolymer.com but in gtmetrix shows that my gzip is disable, I think it will fix tomorrow.