WP-Cache up and running on IIS!

June 6th, 2007 by Mr. Fanrastic

I finally got around to converting wp-cache to work with IIS. Thanks to CpuIdle’s blog for the excellent tutorial, and Yonatanz for his helpful post on Unsought Input that put it over the top!

I’ll list out all the steps together here since Yonatanz’s step is not included in the “official” list at CpuIdle’s blog.

  1. Download the WP-Cache zip file (current version as of writing is 2.1.1) and unzip into wp-content/plugins folder.
  2. If you’re planning to run WP-Cache on IIS, you’ll first need to update wp-cache-phase1.php. Problem is that IIS apparently doesn’t set the REQUEST_URI server variable as expected. There are two ways to fix this issue, depending on how you are managing permalinks.

    The first way to fix this issue is to replace
    This step was contributed by Unsought Input. I believe this works if you have used the pathinfo php.ini method described here.

    The second way to fix this issue was contributed by Yonatanz and it is what worked for me. I am using the 404-redirect method to enable permalinks which can be found over at Keyboard Face. This technique should also work for isapi_redirects. All you need to do is replace

  3. Copy wp-content/plugins/wp-cache/wp-cache-phase1.php to wp-content/advanced-cache.php (not really sure why this isn’t simplified by the author).
  4. Open the standard wp-config.php file and add define('WP_CACHE', true);
  5. Now comes the tricky part:
    open wp-content/plugins/wp-cache/wp-cache.php in your favourite text editor. Search for the wp_cache_add_pages function and change the function code like this:

    add_options_page('WP-Cache Manager', 'WP-Cache', 5, 'wp_cache/wp_cache.php', 'wp_cache_manager');

    The reason the original code doesn’t work is that the original __FILE__ resolves to wp_cache\wp_cache.php which some browser eat and convert to wp_cachewp_cache.php, which doesn’t exist.

  6. The second problem is that WP-Cache checks for installation step 2) in a windows-incompatible manner. Search for the wp_cache_check_link function. Change the first three lines after the variable declaration in this way:

    # if ( basename(@readlink($wp_cache_link)) != basename($wp_cache_file)) {
    # @unlink($wp_cache_link);
    # if (!@symlink ($wp_cache_file, $wp_cache_link)) {
    if (!file_exists($wp_cache_link)) { {

  7. Finally, if you are running an older version of WP-Cache, open wp-content/plugins/wp-cache/wp-cache-phase2.php and search for ob_end_clean(); and replace with ob_end_flush();. Without this change the cached page contents are not written back when the page is initially cached. It’s unclear to me if that works under *nix, I assume it couldn’t. This appears to have been fixed in WP-Cache 2.1.1.
  8. That’s it- you’re done. Now goto Options/WP-Cache and turn caching on.

The above list is essentially the same as the original one on the CpuIdle blog, but with Yonatanz’s step integrated into Step 2 and a few minor updates.

Tags: , ,

4 Responses

  1. Wes F.

    This was a lifesaver! I have tried for so many weeks getting this thing to work and these instructions worked like a charm! Thanks again!!!!!!!

  2. polyphony

    Thanks for this tutorial. Very helpful.

  3. juust out

    brilliant post!
    my index page took 5 seconds to load on an IIS, that became a problem when i started to submit the site to directories, I was getting bad grades on the site. cool post.

  4. Cache Wordpress on IIS | juust.org php serp and pagerank tools

    [...] is slow, you will need a cache to speed it up and might run into some problems, if so : check out WP-Cache up and running on IIS on fanrastic.com. A very simple explanation on how to get the Wp-Cache plugin for WordPress running [...]

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.