简体   繁体   中英

Website on IIS server, gzip cache not working

I have a problem. I need to make PageSpeed scores as high as possible on my website. The thing is that the website is hosted on Microsoft IIS server and I can't turn on the gzip like I used to using .htaccess file on Apache server.

I found the solution that I need to edit the web.config file and this code:

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

But it doesn't help at all and PageSpeed tests still shows that my resources like .jpg, .js or .css files doesn't have an expiration date. Although they do have a gzip properties if I inspect them in browser network tool.

Any ideas what I could do to make the website pass the tests?

You might want to consider CDN. Specially for static files like CSS, images and .js files.

CDN lets you specify a TTL and that is probably what you are looking for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM