Click here to Skip to main content
Click here to Skip to main content

Optimize WordPress Speed Hosted on IIS

, 18 Sep 2013
Rate this:
Please Sign up or sign in to vote.
How to optimize WordPress speed hosted on IIS

If you’re interested in getting a high score in ySlow or PageSpeed for your blog and your blog happens to be hosted on IIS of Windows Server, here are some tips:

1. Enable gzip

  1. To enable gzip on IIS, first add Dynamic Content Compression Role Services for IIS.

    image

  2. If your site is running with Application Pool Identity account, you need to grant IIS apppool\[your application pool name] user full control access to the folder %SystemDrive%\inetpub\temp\IIS Temporary Compressed Files. This is the default temp folder which is used by IIS for content compression. Double click the following icon to see which is the default folder for compression in your situation.

    SNAGHTML1b83934

  3. In your site’s Web.Config file, under system.webServer element, add the following configuration:
        <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" />
  4. Check with Firebug or Chrome developer tools if there’s Content-Encoding is gzip in the header of your site’s HTTP response:

    image

2. Combine JavaScript File

For example, your site has a list of JavaScript files, you can:

  1. Combine them into one single file by the following command:
    copy /b *.js source.js
  2. If you’re using SublimeText, install the Sublime-Minifier plugin, hit ctrl+alt+shift+m, compress the source.js to source.min.js.
  3. Replace the JavaScript files with the compressed file.

3. Add Expiration for Static Files

  1. In your site’s Web.Config file, again, under system.webServer element, add:
    <staticContent>
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="3.00:00:00" 
      cacheControlCustom="public" />
    </staticContent>
  2. If you have a favicon, under configuration element, add:
    <location path="favicon.ico">
      <system.webServer>
        <staticContent>
        <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" 
        cacheControlCustom="public" />
        </staticContent>
      </system.webServer>
    </location>

You can adjust the time according to your situation.

4. Add *.css File in Header and *.js Files on the Bottom of the Page

I use Add to Header and Add to Footer plugin to insert CSS files and JS files. Place your CSS files to header and JavaScript files to footer.

After the steps above, your site probably will have a better score in ySlow and PageSpeed. Happy blogging! Smile

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

JIN Weijie
Software Developer (Senior) Honeywell
China China
ASTreeView, the best FREE treeview control for ASP.NET.
Follow on   Twitter

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 18 Sep 2013
Article Copyright 2013 by JIN Weijie
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid