Click here to Skip to main content
15,888,177 members
Articles / Web Development / IIS

Optimize WordPress Speed Hosted on IIS

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
18 Sep 2013CPOL1 min read 13.2K   1  
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:
    XML
        <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:
    XML
    <staticContent>
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="3.00:00:00" 
      cacheControlCustom="public" />
    </staticContent>
  2. If you have a favicon, under configuration element, add:
    XML
    <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)


Written By
Software Developer (Senior) Honeywell
China China
ASTreeView, the best FREE treeview control for ASP.NET.

Comments and Discussions

 
-- There are no messages in this forum --