Speed up WordPress on IIS 7.0

Since the time this article has been written the WP Super Cache plugin has changed a lot. I cannot guarantee at this point that the instructions below will work. Note that new caching plugins have been developed that support IIS better. I recommend to try out W3 Total Cache plugin which has support for IIS and WinCache.

The performance of WordPress may be sufficient for an average blog that gets a few page hits per minute. However, if your blog post suddenly shows up on digg.com or any other social networking site, it may become challenging for server to handle such huge spike in traffic. A few options exist to help server to cope with flood of requests:

  • IIS Output Caching
  • WP Cache plugin for WordPress
  • WP Super Cache plugin for WordPress

In this post I will explain the benefits and drawbacks of each option and walk through the steps for configuring IIS and WordPress to use those options.

Prerequisites

Before performing the configuration steps described in this post, it is necessary to complete the following prerequisites:

  1. Install WordPress (Follow the instructions in this article or use the instructions from the official WordPress site).
  2. Install Microsoft URL Rewrite Module 1.1 for IIS 7
  3. Enable “Pretty Permalinks” in WordPress by following steps described in this article.

IIS Output Caching

IIS 7.0 has a very powerful output caching infrastructure, which can cache response data in kernel-mode (http.sys) and in user-mode memory space (IIS worker process). The Output Caching can be used with static web resources as well as with semi-dynamic web applications, where the content is generated dynamically, but is not likely to change from request to request. A blog engine is a perfect example of semi-dynamic web application.

To enable IIS Output Caching for WordPress you can use IIS Manager UI:

EditCacheRule

Or add this configuration section into the web.config file located at the root folder of the WordPress site:

<caching>
<profiles>
<add extension="*" policy="CacheForTimePeriod"
kernelCachePolicy="CacheForTimePeriod"
duration="00:00:30" />
</profiles>
</caching>

With this configuration IIS will cache the response generated by WordPress in memory for 30 seconds, thus avoiding heavy script processing and database I/O for all subsequent requests. This would increase the throughput significantly – for example on my Virtual PC the WordPress throughput grew from 10 requests per seconds to more than 2500 requests per seconds after enabling Output Caching.

However, there are certain drawbacks from using Output Caching. Some of the dynamic blog features are lost when cached page is served instead of a page generated by WordPress. For example, when a visitor submits a comment for a blog post there will be no confirmation message shown to indicate that the comment has been submitted. This is because the page shown to the user after comment submission is served from cache. This may cause visitor to submit same comment several times. This problem can be somewhat mitigated by reducing the cache timeout, but there is still a chance that stale page may be served to a visitor after comment submission. To reliable prevent this from happening a more customized solution for WordPress is necessary, which is a WP Super Cache plugin.

WP Cache and WP Super Cache

WP Super Cache is a very popular plugin that generates temporary static html pages from dynamic WordPress blog. After a html file is generated the server will serve that file instead of processing the comparatively heavier and more expensive WordPress PHP script. Since this is a WordPress-customized solution, it is able to smartly handle such situations such submission of comments or serving pages to logged on users. Specifically, the plug in will serve static html pages only to:

  1. Users who are not logged in
  2. Users who have not left a comment
  3. Or users who have not viewed a password protected post.

Typically 99% of the visitors do not do any of the above actions, so the static html pages will be served most of the time, thus increasing server throughput significantly.

WP Super Cache plugin has two modes of operation: WP-Cache and WP-SuperCache. With WP-Cache the static files are still generated but every request will require loading of PHP engine to serve those files. WP-SuperCache relies on URL rewriting to bypass PHP altogether when serving cached static files.

To configure WP Super Cache on IIS 7.0 follow these steps:

Step 0: Make sure that wp-content folder is writable by web server

Step 1: Download the WP Super Cache plugin and unpack it into the WordPress plugins folder “wp-content\plugins”. This will create “wp-content\plugins\wp-super-cache” folder.

Step 2: Copy the file “wp-content\plugins\wp-super-cache\wp-cache-phase1.php” to “wp-content\advanced-cache.php”

Step 3: Add the following rewrite rule to the web.config file located at the root folder of WordPress site. Make sure that the “WP Super Cache” rule is before the WordPress rule for pretty permalinks. Typically the <rewrite> section will look as below

<rewrite>
<rules>
<rule name="wp super cache" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
<add input="{QUERY_STRING}" pattern=".*=.*" negate="true" />
<add input="{QUERY_STRING}" pattern=".*attachment_id=.*" negate="true" />
<add input="{HTTP_COOKIE}" pattern="^.*(comment_author_|wordpress|wp-postpass_).*$" negate="true" />
<add input="{HTTP_USER_AGENT}" pattern="^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).*" negate="true" />
<add input="{DOCUMENT_ROOT}/wp-content/cache/supercache/{HTTP_HOST}/{R:1}index.html"
matchType="IsFile" />
</conditions>
<action type="Rewrite" url="wp-content/cache/supercache/{HTTP_HOST}/{R:1}index.html" />
</rule>

<rule name="Wordpress Pretty Permalinks" patternSyntax="Wildcard">
<match url="*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>

Step 4: Add the following line into the wp-config.php file above the “require_once(ABSPATH.’wp-settings.php’);” line:

define( 'WP_CACHE', true );

Step 5: Login to WordPress and activate the plugin by going to “Plugins” tab. Then go to “Settings” tab and click on “WP Super Cache”. If everything was configured correctly you should see the plugin’s configuration page.

Step 6: Go to “wp-content\cache” folder, which should have been created when plugin was activated. Create a new web.config file there, open it and paste the following content inside:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Cache-Control" value="max-age=300, must-revalidate" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>

This configures IIS to send Cache-Control response header for any of the cached html pages. That header will force the browser to expire the locally cached response after 5 minutes.

To check that the WP Super Cache actually works, set its status to ON in the plugin configuration page, then clear all the browser cookies and make a request to the blog page. Alternatively you can use WFetch to make a request. If WP Super Cache works then when you make a request to http://wordpress/2008/04/hello-world/, the response will be cached as a static file in \wp-content\cache\supercache\wordpress\2008\04\hello-world\index.html. When next time you request the same page, the rewrite rule “WP Super Cache” will rewrite the URL to the “wp-content\cache\supercache” folder, thus IIS will serve static html file without even invoking PHP engine.

Conclusion

Here is the comparison of server throughput in requests per second with three output caching solutions for WordPress when requesting http://wordpress/2008/04/hello-world:

PerfResults

The performance of WP Super Cache is comparable with performance of IIS Output Caching because with WP Super Cache IIS is just serving static files, which is what IIS is very good at.

So, when to use which option? Here are the pros and cons of each caching solution:

Pros Cons
IIS Output Caching
  • Very easy to configure
  • Significantly improves site throughput
  • May prevent confirmation message from showing up when submitting comments
WP-Cache
  • Works without URL rewriting
  • Correctly handles comments submissions and other visitors’ actions
  • Not that significant performance gain comparing to other options
WP-SuperCache
  • Significantly improves site throughput
  • Correctly handles comments submissions and other visitors’ actions
  • More complex to setup and configure comparing to other options

27,667 views

ruslany on December 23rd 2008 in PHP, WordPress

PoorFairAverageGoodExcellent (5 votes, average: 5.00 out of 5)

57 Responses to “Speed up WordPress on IIS 7.0”

  1. Gravatar Imagerukeba responded on 24 Dec 2008 at 1:52 am #

    Very nice article!
    But “That header will force the browser to expire the locally cached response after 5 seconds.” must be “… after 5 minutes.”

  2. Gravatar Imageruslany responded on 24 Dec 2008 at 9:25 am #

    Thanks for correction, rukeba! I’ve updated the post.

  3. Gravatar ImageBradford responded on 29 Dec 2008 at 8:19 pm #

    Thank you for this post. Is it good or bad to use both methods of caching? Or is it just unnecessary?

  4. Gravatar ImageBradford responded on 29 Dec 2008 at 8:21 pm #

    In addition – I run a private blog that doesn’t get much traffic. Would IIS caching improve performance where Super-Cache won’t?

  5. Gravatar Imageruslany responded on 30 Dec 2008 at 10:16 am #

    I guess both methods – IIS Output Caching and WP Super Cache – can be used at the same time, but I do not think there will be any benefit from using them together.

    On a low traffic blog you would not probably notice any benefit from using IIS output caching. Typically, to keep the dynamic nature of the blog you would need to set the cache expiration time to relatively short period, e.g. 30 seconds. If your blog gets one visitor in 5 minutes, the cache will be almost never used.

  6. Gravatar ImageBradford responded on 30 Dec 2008 at 8:11 pm #

    Right, that makes total sense. I’m just trying to improve performance. Much of that in my case will probably come down to reducing http request and database calls, and WordPress has somewhat of a reputation of being heavy on that end.

    Thanks for your articles on this front by the way, I am impressed with how well it works. Now all I need for IIS is a built-in (probably never going to happen) Java server or an EASY way to tie into Jetty for my JSP pages.

  7. Gravatar Imageeddieliu responded on 19 Jan 2009 at 8:55 pm #

    excellent article! thanks for sharing.

    In step 4 of “configure WP Super Cache on IIS 7.0″, seems we should add … as format below


  8. Gravatar Imageeddieliu responded on 19 Jan 2009 at 8:57 pm #

    gosh, seems I can’t add code in comments. what I say above is adding “rules” and “/rules” for step 4 of enabling wp-super-cache on IIS7.

  9. Gravatar Imageeddieliu responded on 19 Jan 2009 at 9:22 pm #

    My WordPress permalinks is something as http://site/2009/01/100.html (/%year%/%monthnum%/%post_id%.html). After following your steps and changing the matchurl (step4) to “^(\d{4})/(\d{2})/(\d+).html$”, I noticed in the supercache folder only have folders but not cache files.

    For example, by visiting URL http://site/2009/01/100.html, I can find folder \wp-content\cache\supercache\site\20091\100.html (yes, 100.html is a folder name but not file!!). However, no files in this folder. I supposed the plugin should create folder “100″ instead of “100.html”. Do you think it’s the root cause? Did I miss some steps?

    Thanks in advanced!

  10. Gravatar Imageruslany responded on 19 Jan 2009 at 10:50 pm #

    Thanks eddieliu, I’ve fixed the rules example code as you mentioned.

    Regarding the permalink structure. I have not tried wp-super-cache with permalinks that have file extensions at the end but from looking at the plugin implementation I suspect it always uses index.html (or index.html.gzip) as a file name.

    The cache folder may be empty because you are making request from the browser that already has a wordpress cookie saved. In that case the plugin will not create index.html file, even though it will create a folder. One thing you could try is to clean up all the cookies in the browser and then request the URL on your blog. Or use something like WFetch to make a request. See if in that case the index.html file gets created.

  11. Gravatar Imageeddieliu responded on 20 Jan 2009 at 7:11 am #

    Haa… super-cache worked if I accessed from another client… Cool. Thank you, Ruslan.

  12. Gravatar ImageCenk responded on 05 Feb 2009 at 11:12 am #

    At first thank you for the useful article.

    I did everything that you’ve explained but when I “ON” wp superscache, i get the error below

    Warning: include(C:\inetpub\vhosts\filmgani.com\httpdocs/wp-contentC:/inetpub/vhosts/filmgani.com/httpdocs/wp-content/plugins/wp-super-cache/wp-cache-base.php) [function.include]: failed to open stream: Invalid argument in C:\inetpub\vhosts\filmgani.com\httpdocs\wp-content\plugins\wp-super-cache\wp-cache.php on line 49

    Warning: include() [function.include]: Failed opening ‘C:\inetpub\vhosts\filmgani.com\httpdocs/wp-contentC:/inetpub/vhosts/filmgani.com/httpdocs/wp-content/plugins/wp-super-cache/wp-cache-base.php’ for inclusion (include_path=’.;./includes;./pear’) in C:\inetpub\vhosts\filmgani.com\httpdocs\wp-content\plugins\wp-super-cache\wp-cache.php on line 49

    I couldn’t find any solution. Could you please help me? I really want to use it. Thank you.

  13. Gravatar Imageruslany responded on 05 Feb 2009 at 12:09 pm #

    Cenk, it looks like the WPCACHEHOME constant is defined incorrectly.

    Open the wp-content\wp-cache-config.php and check what is the WPCACHEHOME set to. It sould look something like this:

    define(‘WPCACHEHOME’, WP_CONTENT_DIR.’/plugins/wp-super-cache/’);

  14. Gravatar ImageCenk responded on 05 Feb 2009 at 12:42 pm #

    Hey thanks for the fast reply!

    I’ve added the string as you said but I only see a blank page at the moment. Whole site is blank. Here’s my wp-cache-config.php

    $wp_cache_mutex_disabled = 0; //Added by WP-Cache Manager
    $wp_cache_clear_on_post_edit = 0; //Added by WP-Cache Manager
    $wp_cache_hello_world = 0; //Added by WP-Cache Manager
    define(’WPCACHEHOME’, WP_CONTENT_DIR.’/plugins/wp-super-cache/’);

    $cache_compression = 0; // Super cache compression
    $cache_enabled = true; //Added by WP-Cache Manager
    $super_cache_enabled = true; //Added by WP-Cache Manager
    $cache_max_time = 3600; //in seconds
    //$use_flock = true; // Set it true or false if you know what to use
    $cache_path = WP_CONTENT_DIR . ‘/cache/’;
    $file_prefix = ‘wp-cache-’;

    Anything that I’m skipping?

  15. Gravatar ImageCenk responded on 05 Feb 2009 at 12:44 pm #

    Ok I’ve fixed it but here’s the new error :(

    Warning: Division by zero in C:\inetpub\vhosts\filmgani.com\httpdocs\wp-content\wp-cache-config.php on line 11

    Warning: Division by zero in C:\inetpub\vhosts\filmgani.com\httpdocs\wp-content\wp-cache-config.php on line 11

    Warning: Division by zero in C:\inetpub\vhosts\filmgani.com\httpdocs\wp-content\wp-cache-config.php on line 11

    can you please help?

  16. Gravatar ImageCenk responded on 05 Feb 2009 at 12:56 pm #

    Sir I’ve fixed everything. The plugin works without any problem but when I put the code step 4. I get error from the whole site as

    500 – Internal server error.
    There is a problem with the resource you are looking for, and it cannot be displayed.

    This is the last step that I can’t skip. could you please help?

  17. Gravatar Imageruslany responded on 05 Feb 2009 at 1:32 pm #

    Is it possible for you to enable detailed error messages in IIS and check the error description reported with 500 status code?

    Do you have the URL rewrite module installed?

  18. Gravatar ImageCenk responded on 05 Feb 2009 at 2:10 pm #

    Yes Ive already rewrite module installed. I didnt put the code step 4. from 01 to 19. WpCache works fine but wp supercache dont.

    WP-Cache

    * 3 Cached Pages
    * 0 Expired Pages

    WP-Super-Cache

    * 0 Cached Pages
    * 0 Expired Pages

  19. Gravatar Imageruslany responded on 05 Feb 2009 at 2:16 pm #

    if you web site is filmgani.com then it does not look like you have enabled pretty permalinks, which is necessary for super cache to work correctly.

  20. Gravatar ImageCenk responded on 05 Feb 2009 at 5:15 pm #

    He is the most helpful person i’ve ever seen! He fixed all of my permalink and supercache problems on my windows 2008 server! I don’t know how to thank you! Thank you millions of time!

  21. Gravatar ImageGail responded on 20 Feb 2009 at 11:51 am #

    Hi,
    Great post! I’m trying to follow the installation instructions for the WP-SuperCache plugin and I have a couple of questions.

    1. Instructions in Step 2 say to adjust WPCACHEHOME points to the right place. HOW would one do that? What part of that code line do you change?

    define(’WPCACHEHOME’, WP_CONTENT_DIR.’/plugins/wp-super-cache/’);

    My blog is in a subfolder called: devsite
    Do I need to adjust that line of code at all?
    If so, would this be correct?

    define( ‘WPCACHEHOME’, WP_CONTENT_DIR . ‘devsite/wp-content/plugins/wp-super-cache/’ );

    Question 2:
    Step 4 says that if our pretty permalinks don’t use the same format as yours, we have to adjust the Rewrite code for that. How would one do that? What line of code? Is it this line?

    If so, and my permalinks use the following format:
    /index.php/%category%/%postname%/ then would this be the correct way to change it:

  22. Gravatar Imageruslany responded on 20 Feb 2009 at 4:11 pm #

    Gail, I would recommend first to leave the WPCACHEHOME as is. That worked for me. The WP_CONTENT_DIR should take care of the fact that your blog is in subfolder.

    As with regards to the permalink structure – first you need to configure permalinks to not have index.php in them. Use this article to learn how to do it: http://learn.iis.net/page.aspx/466/enabling-pretty-permalinks-in-wordpress/.

    After you have done this your permalink structure would probably be /%category%/%postname%/. In that case the rule would look as below:

    <rule name="WP Super Cache" stopProcessing="true">
    <match url="^(\w+)/(\w+)/?$" 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}\index.html"
    matchType="IsFile" />
    </conditions>
    <action type="Rewrite"
    url="wp-content/cache/supercache/{HTTP_HOST}/{R:1}/{R:2}/index.html" />
    </rule>

  23. Gravatar ImageCory responded on 22 Feb 2009 at 3:39 pm #

    Hi, very helpful post!

    After following your instructions I managed to get super cache working however I encounter 500 errors when attempting to save or preview a new unpublished draft post. If I publish the post instead of trying to save or preview everything seems ok.

    When I turn off super cache I am able to save and preview the post.

    Looking at the server logs it seems like it has something to do with the way the url is being handled since it doesn’t appear as the pretty permalink in the error detail but instead as “…..blog//p=61″.

    Just wondering if you have run across this problem or have any ideas on getting things straightened out?

    Thanks!

  24. Gravatar Imageruslany responded on 23 Feb 2009 at 10:44 am #

    Cory, what are the error details that you get with 500 error?
    Just now I have tried to save the draft post and yes, I got 500 error. The reason I got it was because I had PHP setting open_basedir in effect and when the post URL was //?p=10 that somehow caused a violation of open_basedir location. If I disable open_basedir then the error does not show up.
    It would be good if super cache was able to handle this error gracefully.

  25. Gravatar ImageCory responded on 24 Feb 2009 at 4:57 pm #

    Yep, that’s exactly what’s happening to me too. I don’t really want to disable open_basedir so I’m currently using super cache in half on mode and it works ok.

    Definitely something that super cache needs to be able to deal with before I switch it back on.

    I just wasn’t sure if it was my setup or a limitation of super cache. But since you were able to duplicate it seems to be the latter.

    Thanks.

  26. Gravatar ImageSam responded on 16 Apr 2009 at 8:28 am #

    I’m seeing the same thing. Any fix for this open_basedir issue?

  27. Gravatar Imageruslany responded on 16 Apr 2009 at 10:20 am #

    Donncha O Caoimh, who is the author of the plugin, has replied to me about that and suggested to try the dev version of the plugin, which does not do any caching when previewing posts. That may fix this specific issue.

  28. Gravatar ImageChris responded on 19 May 2009 at 2:18 pm #

    Thanks you so much for all your help. Every time I need help with WordPress and IIS7 the answer is here!

    So far you have helped me set up wordpress properly for IIS7, configure per site php ini files and now get caching working too!

  29. Gravatar Imagestevi responded on 14 Aug 2009 at 2:28 pm #

    I have configured Wp super cache on IIS 7 according to this article but I am not sure it is actually working.

    When I request a page , it has the “Generated by WP-Super-Cache” html , also Cache Pages count increases in the Wp-Super cache folder and are being created.

    However MySql Administrator Monitoring tools , shows 30 databases queries being made during each page request. That is the same number of requests when Super-Cache is not on.

    I have tried using your Web.Config rule for Super Cache, also tried the using the two rules from the latest Super Cache version – dumped below. Either way queried are still made.

    # BEGIN WPSuperCache

    RewriteEngine On

    AddDefaultCharset UTF-8
    RewriteCond %{REQUEST_URI} !^.*[^/]$
    RewriteCond %{REQUEST_URI} !^.*//.*$
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} !.*=.*
    RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
    RewriteCond %{HTTP_user_agent} !^.*(Android|2.0\ MMP|240×320|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb |hiptop|IEMobile|iPhone|iPod|KYOCERA/WX310K|LG/U990|MIDP-2.0|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|Playstation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|Windows\ CE|WinWAP).*
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
    RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz [L]

    RewriteCond %{REQUEST_URI} !^.*[^/]$
    RewriteCond %{REQUEST_URI} !^.*//.*$
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} !.*=.*
    RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
    RewriteCond %{HTTP_user_agent} !^.*(Android|2.0\ MMP|240×320|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb |hiptop|IEMobile|iPhone|iPod|KYOCERA/WX310K|LG/U990|MIDP-2.0|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|Playstation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|Windows\ CE|WinWAP).*
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
    RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html [L]

  30. Gravatar Imageruslany responded on 14 Aug 2009 at 2:35 pm #

    Which version of the URL Rewrite Module do you have? If you have 1.0 then it is better to upgrade to 1.1, because the rules in this post will only work if you have 1.1.

  31. Gravatar Imagestevi responded on 15 Aug 2009 at 4:51 am #

    it suddenly decided it should start to work, dont ask me how.

    Just wanted to say IIS 6 , and 7 is the best platform out there , and what I setup in iis 7 in 2 days took me 2 weeks on command-interface LAMP. Sure some people love lamp , but for me nothing is giving me back these 2 weeks of googling commands.

  32. Gravatar ImageJamal Zahalka responded on 22 Aug 2009 at 6:08 am #

    If I use IIS way , how much time it will take till it caches the website

  33. Gravatar ImageJamal Zahalka responded on 22 Aug 2009 at 6:13 am #

    I tried the IIS way
    But after that each time I tried to enter my website , it keeps showing mt\y different page of my website , is that a regular thing

  34. Gravatar Imageruslany responded on 22 Aug 2009 at 7:48 am #

    Whenever a request for a web page or a blog post is made, it creates a cached copy. It should start caching right away.

    If you see that different pages are served for the same request, then most probably the configuration is incorrect.

  35. Gravatar ImageJamal Zahalka responded on 22 Aug 2009 at 8:26 am #

    I did exactly as in the picture of IIS Output Caching

    what could I done wrong

  36. Gravatar ImageJamal Zahalka responded on 23 Aug 2009 at 3:36 pm #

    I found solution for it , I only needed to choose Advanced and put “*” in the string

  37. Gravatar Imagesunnybear responded on 17 Sep 2009 at 4:32 am #

    To improve performance of your weblog you can also use Web Optimizer – http://wordpress.org/extend/plugins/web-optimizer/ . It increase client side load speed, applies gzip, merging, minify, caching, and even more for your static assets.

  38. Gravatar Imageamar responded on 02 Feb 2010 at 5:41 am #

    We have permalink structure containing “index.php” in it and we cannot remove that text. If we remove it, the super-cache works well. Is there any way by which we can have “index.php” and still super-cache works?
    please help.

  39. Gravatar Imageruslany responded on 02 Feb 2010 at 4:55 pm #

    @amar: I do not think the super-cache will work with permalink structures that have index.php.

    What is the reason not to use the standard permalink structure?

  40. Gravatar Imageamar responded on 02 Feb 2010 at 9:00 pm #

    If we remove “index.php” from our blog URL it will affect our tweet count of each post.

  41. Gravatar ImageRafael responded on 14 Mar 2010 at 1:32 am #

    Hi Ruslany,

    Thanks for this article it helps running a WP blog on IIS 7 easier. I set up my WP-Supercache like you described in the article.

    I wanted to check with you that my Rewrite rule was correct since it appears to be different than what you described in the comment about using sub-folders.

    So my site structure is like this:

    http://www.mainsite.com/blog/

    And WP is in the blog directory. So my rewrite rule is like this:

    wp-content/cache/supercache/{HTTP_HOST}/blog/{R:1}/index.html

    The mach URL rule uses Regular Expression with this as the pattern: (.*)

    I check the pages and it works, the sub folders are created under the supercache folder structure with the index.html pages and I check the Page Source and see the Generated by WP-Supercache on the bottom after refreshing and the timestamp is the same, I’m just wondering since it seems to be different in the Rewrite rule that what you described. In the response to Gail’s comment about subfolders you said to not count the subfolder, so I’m confused a little.

    Also the gzip compression is not set up, should I turn this on in the WP-Supercache admin or should I do that on the IIS 7 admin? I’m pretty sure I shouldn’t do both, right?

  42. Gravatar Imageruslany responded on 15 Mar 2010 at 10:11 am #

    @Rafael,

    I think your rewrite rule is correct. I also noticed recently that when WordPress is setup in a subfolder, then this subfolder needs to be included in the rewrite logic. You need to make sure that you include the subfolder in the condition that checks the file existence and then in the action url.

    The best way to ensure that your rule is setup correctly is to enable Failed Request Tracing and check if the rule was evaluated successfully.

    I have never tried the gzip compression with the wp-super-cache on windows. I do not know if it will work or not.

  43. Gravatar ImageRafael responded on 20 Apr 2010 at 3:22 am #

    @Ruslany,

    Thanks for your reply. I have a detailed explanation of what is happening, but it’s confusing, according to what you’ve explained and what I know of the URL Rewrite Module. I’ll explain below, I think we’re close to having a handle on a confusing issue.

    So as stated above, my WordPress blog is set up in a subfolder of my main site like this: http://www.example.com/blog/

    The Rewrite Rule is set up in the Web.Config inside of this subfolder and the pattern to match and rule is –

    The URL Rewrite rule for the WP Super Catch has this for checking if the file exists -

    And the action type is this -

    It would seem that the condition to check that the file exists is missing the “blog\” before the {R:1} but when I navigate to a post on my WP blog the post shows correctly with no issues, the folders and index.html file is created by WP Super Cache under the supercache subfolder of cache in the wp-content folder. The folder structure is exactly as it should be, with the blog subfolder in the path.

    When I check the page a second time, it loads quickly from the Super Cache and I check the source and it reads as follows:



    So this indicates that everything is working fine, the Super Cache is active. But according to the “blog/” not being in the condition that the File Exist, it shouldn’t be. Any idea as to what is going on and if there’s something to fix?

    Also my regular WP Rewrite rule for Permalinks is as follows:

    This is set up in the Web.config of the blog subfolder and works, but again the lack of having the “blog/” folder mentioned in the rule seems like it wouldn’t allow it to work, if you have any insight into why it does work, please let me know.

    I’ll keep on trying different combination and seeing what happens and note anything worthwhile here.

    I’ll have to look up doing the Failed Tracing with URL Rewrite, last time I looked into that it was involved. Wouldn’t the RegXp testing feature in the URL Module within the IIS 7 Manager tell me if there’s a match? Or at least tell me what the R:1 is, so I can tell, right?

  44. Gravatar ImageRafael responded on 20 Apr 2010 at 3:45 am #

    Sorry I didn’t encode the XML

    The Rewrite Rule is set up in the Web.Config inside of this subfolder and the pattern to match and rule is –

    <rule name="WP Super Cache" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
    <match url="(.*)" />

    The URL Rewrite rule for the WP Super Catch has this for checking if the file exists -

    <add input="{DOCUMENT_ROOT}\wp-content\cache\supercache\{HTTP_HOST}\{R:1}\index.html" matchType="IsFile" />

    And the action type is this -

    <action type="Rewrite" url="wp-content/cache/supercache/{HTTP_HOST}/blog/{R:1}/index.html" />

    When I check the page a second time, it loads quickly from the Super Cache and I check the source and it reads as follows:

    <!– Dynamic page generated in 0.990 seconds. –>
    <!– Cached page generated by WP-Super-Cache on 2010-04-20 02:51:42 –>
    <!– super cache –>

    Also my regular WP Rewrite rule for Permalinks is as follows:

    <rule name="wordpress" patternSyntax="Wildcard">
    <match url="*" />
    <conditions>
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="index.php" />
    </rule>

    So if you can fill that in with the last post, you’ll see what I mean sorry about that.

  45. Gravatar ImageRafael responded on 20 Apr 2010 at 3:56 am #

    OK

    I Changed the rule to check if the index.html file exists to this -

    <add input="{DOCUMENT_ROOT}\wp-content\cache\supercache\{HTTP_HOST}\blog\{R:1}\index.html" matchType="IsFile" />

    And that works also, it actually loads noticeably faster without hardly a browser post back, though the way it was before I made this change was also pretty instantaneous, I wouldn’t have noticed had it not been doing this one after the other and the last time was super quick. So why would it work both times, if this last time is correct?

  46. Gravatar ImageFrancesco Cosentino responded on 06 May 2010 at 6:37 am #

    A good post.
    I’m using WordPress running under IIS7.5 with MS SQL Server 2008 x64 as database.
    I prefer to flag the file notification change option, this setting prevents the missing confirmation message when posting new data.
    I suggest you to prevent caching under the wp-admin directory! This could help ;)
    Let me know and visit our blog!
    F.

  47. Gravatar ImageHayden responded on 12 Jan 2011 at 8:36 am #

    Is this to be used WITH wincache? Or does wincache replace wp-super-cache?

    thanks

  48. Gravatar Imageruslany responded on 12 Jan 2011 at 9:40 am #

    Conceptually, the wp-super-cache is somewhat similar to IIS output cache. The explainations of how those compare to wincache is here.

  49. Gravatar ImageHayden responded on 12 Jan 2011 at 9:53 pm #

    Thanks read it and understand. I now use Quick Cache with Wincache enabled = awesomeness

  50. Gravatar ImageHayden responded on 15 Jan 2011 at 3:22 pm #

    I’m just thinking we get around 50,000 page views per day and we use Quick Cache which is a lot faster than WP Super Cache. Of course, it caches to DISK.

    IIS Output cache would cache to Memory. I’m thinking it might be performance improvement to enable both? Enabling output cache to cache for say 10 seconds?

    Does output cache remove files based on least used/hits or does it remove files just based on last access? I guess if IIS Output cache at say 10 – 30 seconds can be filled with only the most used pages then it could make sense to enabled both on busy site.

    Any thoughts, clarifications, suggestions on running both so that cache is delivered from memory and not disk?

  51. Gravatar ImageHayden responded on 15 Jan 2011 at 5:04 pm #

    As per Output caching issues can CacheUntilChange help?

    CacheUntilChange detects a change to the underlying resource.

    Read about it here:
    http://learn.iis.net/page.aspx/710/configure-iis-7-output-caching/

  52. Gravatar Imagesahil responded on 30 May 2011 at 3:59 am #

    Hello ruslany,

    I was going through this article ,
    As i also want to implement the same but the issue is that I have already written some rules in web.config for permalink structure but how to go abt implement only super cache stuff

    Kindly respond asap

  53. Gravatar Imageruslany responded on 06 Jun 2011 at 2:47 pm #

    Hi Sahil,

    Since the time I wrote this article there are other caching plugins became available which are designed to work well with IIS. I would recommend to take a look at W3 Total Cache, which has been tested with IIS and also supports WinCache.

  54. Gravatar ImageHector responded on 26 Jul 2011 at 11:49 pm #

    Hi I know this post is a bit old but I have found it very useful anyway. My only question is, I don’t think or see the rewrite rule attempts to send the gzip version if available? I know Super Cache is creating the HTML and the GZIP version for every cached file, but it always sends the uncompressed one. Any ideas how to tweak the rule to try the compressed version first?

    I was using Total Cache on Linux but now we had to move to Windows and since this is the only tutorial I found that worked and I have zero experience in writing IIS rules, I had to switch to Super Cache. The only thing I miss is the minification which I preferred than using a separate WP Minify.

    Anyway, any help with the Gzip rule would be greatly appreciated!

  55. Gravatar ImageDigitalStudio responded on 28 Aug 2011 at 9:19 pm #

    Hi. I followed your post to setup WP super cache on one of our WP (3.1) sites on IIS 7.5. We noticed once the page views went over 15K pageviews per hour, the site become almost unresponsive. Have you experienced such issues? Caching works really good up to that point though… I’d like to hear your thoughts.

  56. Gravatar ImageTyson responded on 26 Sep 2012 at 6:03 am #

    At this time it appears like Movable Type is the best blogging platform out there right now.
    (from what I’ve read) Is that what you are using on your blog?

  57. Gravatar ImageRobert responded on 19 Apr 2013 at 3:07 am #

    I have a problem in wordpress because output caching works for php files but not for wordpress file.

    Can you please take a look here

    http://stackoverflow.com/questions/15980785/output-caching-in-iis-doesnt-work-for-wordpress-php-files

Trackback URI | Comments RSS

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

XML Markup: If You want to add XML code to the comment please XML encode it first, otherwise the code will not show up.

Recently Published Articles