Tuning WordPress with Helicon Ape on IIS7 (permalinks, browser/server caching, compression)

WordPress is a highly popular and rapidly growing open source CMS providing powerful blog-designing facilities. Accounting for its popularity we decided to write an article in which we’ll show how to optimize, speed up, prettify WordPress operation using Helicon Ape. So, let’s start.
Prerequirements: Windows 2008/Vista, IIS7, FastCGI, Helicon Ape

Step 1. MySQL

After MySQL installation run MySQL Command Line Client and execute the following command:

create database wordpress;

Step 2. PHP

Install PHP into C:\inetpub\php to inherit NTFS permissions of IIS directory. It is of importance that C:\inetpub\php\php.ini contained the following directives:

magic_quotes_runtime = Off
extension_dir = "C:\inetpub\php\ext\"

After ensuring the directives are in place you need to register PHP in IIS configuration. To accomplish this:

  • open IIS Manager
  • open Handler Mappings snap-in

  • press ‘Add Module Mapping’ and fill the fields in the opened window in accordance with the next screenshot (all images are clickable)

Step 3. WordPress

Download the latest WordPress version

Unzip the package into C:\inetpub\wwwroot\wordpress

Rename wp-config-sample.php into wp-config.php.

Adjust MySQL connection:

Create a blog

Now in Administrative panel you can set SEO-friendly format for your links, e.g: /%post_id%/%postname%

Your links will now look like http://localhost/wordpress/2008/uncategorized/hello-world

instead of http://localhost/wordpress/?p=123. If you now attempt to access any of the pages on your blog,

you’ll get 404 Not Found error

And that is defenitely not the desired result!

Step 4. Helicon Ape

It’s time to fix the above inconveniences and accelerate WordPress.

We’ll use the following Helicon Ape modules:

4.1 mod_rewrite

It’ll assist us in handling SEO-friendly URLs.

Open Helicon Ape Manager and uncomment/add the following line in httpd.conf to enable mod_rewrite:

LoadModule rewrite_module  modules/mod_rewrite.so

Now in Helicon Ape Manager browse to WordPress folder and put the following code to .htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [NC,L]

This piece of code checks whether the requested resource is physically located on the disk and if it doesn’t, performs rewriting to index.php.

Save changes to .htaccess. Request any blog page once again… It works!

Yes, it does… but not the best way… So we are moving on! ‘Cause only the best is good enough:)

4.2 mod_expires: client/proxy content expiration

With this module we’ll adjust browser cache so that the browser doesn’t send excess requests to the server. Go back to httpd.conf in Helicon Ape Manager and uncomment/add the following line:

LoadModule expires_module  modules/mod_expires.so

Subsequent lines (being put to .htaccess) will tell browser cache that images, css and JavaScripts must not be requested from the server (but rather taken from cache) within 1 day after retrieving resource for the first time:

ExpiresActive On
ExpiresByType image/jpeg "access plus 1 days"
ExpiresByType image/gif "access plus 1 days"
ExpiresByType text/css   "access plus 1 days"
ExpiresByType application/x-javascript  "access plus 1 days"

Let’s check what’s changed. The first request grabs all page resources and for each image, css and JavaScript sets the header Cache-Control: max-age=86400

Upon consequent requests to that page the browser does not ask for images, css and JavaScripts from the server but takes them from the cache until max-age expires.

4.3 mod_gzip

Are you enjoying the process? Then let’s implement the next stage. To make things even better, let’s apply on-the-fly compression that will reduce traffic and speed up page load. In our irreplaceable Helicon Ape Manager please uncomment/add the following line inside httpd.conf:

LoadModule gzip_module  modules/mod_gzip.so

And put the following lines into .htaccess in WordPress folder:

mod_gzip_on yes
mod_gzip_item_include Mime ^text/.*

These directives instruct Helicon Ape to compress only those resources which type starts with “text/”, i.e. all text, .html and .css files. Usually images and video compression is useless.

Uncompressed page had Content-Length: 5152, the same page after compression became as small as Content-Length: 2168. So, we’ve managed to reduce the amount of info to be transferred almost twice.

4.4 mod_cache

We are coming to the final and in conclusion we’ll enable server-side caching. Instead of requesting the same page from the server again and again Helicon Ape saves the copy of server response and fires with it when corresponding page is needed.

Uncomment/add the following line in httpd.conf (using Helicon Ape Manager):

LoadModule cache_module  modules/mod_cache.so

We’ll only cache index.php page. It will be stored in cache for 30 seconds so that the site looked dynamic. There’s no need to cache static files (.html, .css, images, Flash, videos) because IIS processes them really fast.

Note! It is worth mentioning that cache distinguishes query string parameters, thus it will store different snapshots for different blog pages.

There are some shortcomings of this type of caching (semi-dynamic web application). E.g. if the user posts a comment on the blog, it will see the result (his post) immediately, but another user browsing this page will only see it in 30 seconds (after cache expires). This issue may be resolved by reducing the time snapshot lives in cache, but it should nevertheless be taken into account.

Put the following lines into .htaccess in WordPress folder:

<Files index.php>
ExpiresByType "text/html; charset=UTF-8" A30
CacheEnable mem 
CacheVaryByHeaders Original-Url 

Let us compare the productivity with and without cache. On our testing virtual machine we’ve obtained the following values:

  • without cache – 7.45 requests per second

  • with cache – 711 requests per second!

4.5 mod_headers

The last drop we want to add to our WordPress-based dish will hide IIS from robots and scanners.

You need to uncomment/add the following line in httpd.conf:

LoadModule headers_module  modules/mod_headers.so

And put the only line into .htaccess:

Header set Server "Apache/2.2.9 (Unix)"

Now our IIS appears to the world like

Congratulations to everyone who came to finish! It’s all done now! Enjoy flawless and fast WordPress operation and stay with us!

Best regards,

Helicon Team.

This entry was posted in Helicon Ape and tagged . Bookmark the permalink.

9 Responses to Tuning WordPress with Helicon Ape on IIS7 (permalinks, browser/server caching, compression)

  1. Michael says:

    Great article, love the screenshots. What’s that nifty performance benchmark program?

  2. Tony says:

    Hi, Michael!
    Thanks for your feedback! We are happy you enjoyed the screenshots:)
    As for the benchmark program, it’s ab.exe from Apache distributive (http://httpd.apache.org/docs/2.2/programs/ab.html).

  3. mgpix says:


    I'm trying to have the permalink working on my wordpress but can't get it to work.

    With the .htaccess in place, I have all the url returning the homepage.

    It seems that the rewriting is taken into account but only to "index.php" whithout the arguments. As if http://www.mydomain.com/category/cat1 was rewrited into http://www.mydomain.com/index.php instead of http://www.mydomain.com/index.php/category/cat1

    Any idea how this could be fixed ?

  4. Tony says:

    @mgpix: thanks for your question. If possible, could you re-post it on our forum (http://www.helicontech.com/forum/) so we could discuss it in more details.

  5. khassebr says:

    Do the cache settings documented here mess with Google Analytics in any way?

    • ruslan says:

      Google Analytics works in client browser, not at server. And that caching do not apply to Google Analytics and it is working as usually.

  6. essays says:

    Well done, my essay was a real success among tutors. I am so satisfied with your work.

  7. too much fish oil says:

    I was wondering if you ever considered changing the layout of your website? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having one or two images. Maybe you could space it out better?

  8. Блог о путешествиях says:

    Thx for this great information that you are sharing with us!!!