Using WP Super Cache with IIS 7

If you are lucky enough to have attracted some traffic on your WordPress blog, you may find yourself stuck with an overloaded web server that gets bombarded from links on Google, Digg or Twitter.

Tags: iis infrastructure seo wordpress

Overview

Sooner or later you will discover the WP Super Cache plug-in for WordPress, but perhaps you’re running it on IIS 7 instead of Apache, and support for that is somewhat limited. Luckily, a two year old blog post on IIS Blogs still appears to work for the latest version of WordPress (3.0.1 at the time of this writing) and IIS 7.5, so that they will be presented here again in a somewhat condensed form.

Prerequisites

The steps below make the following assumptions:

Installing the Plug-in

The quickest way to install the plug-in is to use the plug-in manager in WordPress:

  1. Log on to your WordPress blog as administrator
  2. In the navigation menu, click Plugins → Add New
  3. Search for the term WP Super Cache
  4. Click Install Now in the search result for WP Super Cache.

Configuring URL Rewriting

WP Super Cache uses URL rewriting to redirect external requests to your blog posts and pages to a separate directory that contains static HTML and GZIPed pages. These static files are automatically created and maintained by the plug-in, and they are the reason for the blog’s improved performance, because they do not require PHP and database execution.

The WP Super Cache plug-in has been written for the Apache web server and will attempt to create and update .htaccess files within your WordPress installation, but those files have no effect when using IIS as the web server.

To configure URL rewriting for IIS, perform the following steps:

  1. Open the Web.config file in a text editor
  2. Add the following block right after the <rules> section near the top of the file and before the <rule> entry for the WordPress Pretty Permalinks configuration:
    <rule name="WP Super Cache" stopProcessing="true">
    <match url="^(\d{4})/(\d{2})/(.+?)/?$" ignoreCase="false" />
    <conditions>
      <add input="{REQUEST_METHOD}" negate="true" pattern="POST" ignoreCase="false" />
      <add input="{QUERY_STRING}" negate="true" pattern=".*=.*" ignoreCase="false" />
      <add input="{QUERY_STRING}" negate="true" pattern=".*attachment_id=.*" ignoreCase="false" />
      <add input="{HTTP_COOKIE}" negate="true" pattern="^.*(comment_author_|wordpress|wp-postpass_).*$" ignoreCase="false" />
      <add input="{DOCUMENT_ROOT}\wp-content\cache\supercache\{HTTP_HOST}\{R:1}\{R:2}\{R:3}\index.html" matchType="IsFile" />
    </conditions>
    <action type="Rewrite" url="wp-content/cache/supercache/{HTTP_HOST}/{R:1}/{R:2}/{R:3}/index.html" />
    </rule>
  3. Save and close the file.

The rules shown above apply to Pretty Permalinks in the Year/Month/Title format, for example http://blog.gerke-preussner.de/2010/11/using-wp-super-cache-with-iis-7-2/, and they will have to be adjusted for different Permalink formats.

Enabling Caching in WordPress

To enable serving cached WordPress files, make the following changes in the WordPress configuration file:

  1. Open the file wp-config.php from the root directory of your blog in a text editor
  2. Add the following line before the first require_once() function call at the bottom of the file:
    define('WP_CACHE', true);
  3. Save and close the file.

Activating the Plug-in

Finally, the plug-in can be activated in the WordPress administration interface:

  1. In the navigation menu click Settings → WP Super Cache
  2. Click on WP Super Cache
  3. On the Advanced tab…
    • Check Cache hits to this website for quick access
    • Select Use mod_rewrite to serve cache files.

The warning messages about Mod rewrite may not be installed and Rewrite rules must be updated apply to the Apache web server and can be ignored.

The plug-in should now be fully functional, and cached versions of the blog posts and pages should automatically be created in the \wp-content\cache\supercache directory. Please note that the plug-in will create sub-directories for each year, month and page.

相关推荐

php7.3 pregmatch problem

This question already has an answer here: preg_match(): Compilation failed: invalid range in character cla …

暂无评论

微信扫一扫,分享到朋友圈

Using WP Super Cache with IIS 7