Attention! Helicon Tech Blog has moved to

Wednesday, December 24, 2008

Guide: 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/

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/

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/
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/
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/
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.

Monday, December 22, 2008

Helicon Ape - firm step ahead!

Pretty much time has elapsed since the release of the first public build of Helicon Ape ( We've made every effort to spend this time as efficiently as possible to make you a small Christmas gift. And here it is ready to rejoice you!

The main improvements in build 12 include:
  • check of available updates
  • kernel cache support
  • password generator for basic/digest authentication
  • NE, ENV flags processing in mod_rewrite
Here's the complete change log.

Friday, December 19, 2008

Guide: URL-rewriting basics and map-files application

Lack of understanding of basic URL-rewriting concepts often leads to the problems with rules-writing. So we decided to give a brief and simple explanation of some general concepts.

URL-rewriting allows to substitute real (often ugly) URLs with pretty ones and expose them to users as well as to search engines. The idea is that the user requests for example (this link is indexed by search engines) and in reality browser shows the content of say (that is real physical file on your server).

Regular expressions empower you to create more complex and efficient rules and add conditions to gain better flexibility and performance.

There are several ways of writing rules; the choice depends on a specific situation.For example if you have these pages:

Real URLs            Rewritten (pretty) URLS
/index.php?q=444 => /page.html
/index.php?q=345 => /another-page.html
/index.php?q=999 => /about.html
You may EITHER use the following rules to implement rewriting functionality:
RewriteRule ^/page\.html$         /index.php?q=444 [NC,L]
RewriteRule ^/another-page\.html$ /index.php?q=345 [NC,L]
RewriteRule ^/about\.html$        /index.php?q=999 [NC,L]
you may use map-files (which are preferable in this case):

Info: Map-file is a .txt file containing pairs of values written in two columns (as shown below). The first (left) column represents the value to which RewriteRule matching result will be compared, and the corresponding value in right column represents the result that will be placed into the substitution URL.

In our example we’ll create a text document (e.g. map.txt) in the folder with .htaccess and put in the following:

page           444
another-page   345
about          999

And our configuration file (.htaccess) will have the following look:

# Set a variable (“map”) to access map.txt from config
RewriteMap map txt:map.txt

# Use tolower function to convert string to lowercase
RewriteMap lower int:tolower

# Get requested file name
RewriteCond %{REQUEST_URI} ^/([^/.]+)\.html$ [NC]

# Seek file name in map-file
RewriteCond ${map:${lower:%1}|NOT_FOUND} !NOT_FOUND

# Perform rewriting if the record was found in map-file
RewriteRule .? /index.php?q=${map:${lower:%1}} [NC,L]
Helicon Ape Manager

Note! Map files are case-SENSITIVE. So, “Page” will not match “page”. That is why it is advisable to use tolower function that converts matched part to lowercase before comparing it with map-file entries. Don’t forget that in this case all map-file records should also be lowercase.

Map-files are particularly advantageous when you have to rewrite loads of URLs of the similar pattern. The first benefit is that map-file may have virtually unlimited size (up to several gigabytes); secondly, parsing of a large map-file is much faster than processing of a huge .htaccess (or httpd.conf). We don’t recommend using configuration files with more than 100-150 rules.

Hope this info made in easier for you to grasp the idea of URL-rewriting.

Looking forward to your comments and suggestions.

Sincerely Yours,
HeliconTech Team.

Thursday, December 18, 2008

Guide: How to enable mod_rewrite in Helicon Ape

Hope you've already installed Helicon Ape and are ready to have a look at it. So, let's start!

Run Helicon Ape Manager from Start - Programs - Helicon - Helicon Ape - Helicon Ape Manager.

To enable mod_rewrite in Helicon Ape you should simply add/uncomment the following derective in httpd.conf:

LoadModule rewrite_module  modules/
Helicon Ape Manager

1. The easiest way to check if mod_rewrite is working correctly

Now to make sure mod_rewrite operates correctly add the following code into .htaccess in the root of your site:

RewriteRule . – [F]

Note! Don't use this directive on live server!

Helicon Ape Manager

Now save changes to .htaccess

Helicon Ape Manager

Make any request to your site. If mod_rewrite works fine, the result will be 403 Forbidden, otherwise you'll get 404 Page not found.

Hurrah! It works! Now let's move on to the real example.

2. Example of basic rewrite rule

Let's create a file, say test.asp, in the root of your site. And put the following code that will show us current date/time

Done? Then put the following rules into the .htaccess in the root of your site

RewriteEngine On
RewriteBase /
RewriteRule ^foo\.htm$ test.asp [NC,L]

Save .htaccess.

If you now request http://localhost/foo.htm, you'll get the content of http://localhost/test.asp.

May your first steps with Helicon Ape be firm and sensible.

Sincerely Yours,
Helicon Team.

Tuesday, December 16, 2008

Monday, December 8, 2008

Subtleties of Unicode transformation in IIS6

Today we want to give you a brief info on what and how is being encoded in IIS6.

When IIS gets a request (e.g. GET /smth), each Unicode character of "smth" should be encoded as %xx in UTF-8 (in our case: GET /%73%6d%74%68).

However, IIS also recognizes non-encoded Unicode (UTF-8, UTF-16, etc.) text (e.g. GET /Şмŧĥ) which it will then convert to UTF-8 equivalent.

In it's turn native encoding for Windows API is UTF-16, thus the request is encoded once again (from UTF-8 to UTF-16). That's why ISAPI module also operates with UTF-16.

To return result to IIS rewritten request should be encoded back to UTF-8 and escaped as %xx because ISAPI does not provide native Unicode API.

Thursday, December 4, 2008

HeliconJet at your service!

Our new small but very useful product - HeliconJet - has got some features fixed. This includes correct ASP.NET pages processing and improved caching of requests with querystring.

Save traffic by compressing and caching files with new HeliconJet!

New LinkFreeze released!

This version of LinkFreeze was built with new Boost library.
And now it supports IPv6.
So, download and enjoy!

Striving for perfection - ISAPI_Rewrite with new fixes

Greetings to everyone interested in SEO and looking for the ways to make your site more pretty for search engines!

We (HeliconTech) have just released a new build of ISAPI_Rewrite that has some small but rather useful enhancements: 
the problem with proxy re-registration upon update was eliminated, 
and secondly
from now on map file defined in httpd.conf may be accessed from any .htaccess. So, if you are using a single map file with different .htaccess files, now there's no need to define in each of them.

You may download and evaluate ISAPI_Rewrite here.