Super Charge Wordpress With Litespeed Cache

Posted By: Tony Baird

Last Updated: Wednesday July 22, 2015

Update: We now have a guide for the LiteSpeed Cache Wordpress Plugin

We recently enabled the ability to utilize Litespeed’s caching functionality which some of our user base has already started taking advantage of.  For the users who have not started utilizing it I’m going to quickly describe it and provide the benefits of it.

The Litespeed cache works similar to that of Apache’s mod_cache while providing the performance of the popular Varnish reverse proxy.  Unlike Varnish however you do not need to deal with the complications of a reverse proxy.  All you need to do in order to enable caching is just add a few mod_rewrite rules to your .htaccess file and you’ll be utilizing it.

For a Wordpress application you would add the following rewrite rules to your .htaccess file:

[php] CacheEnable public / RewriteEngine on RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$ RewriteCond %{REQUEST_URI} !^/(wp-admin|wp-login.php|wp-cron.php) RewriteRule .* - [E=Cache-Control:max-age=120] [/php]

What this code does is enable our page caching except for your login page, Wordpress admin and your Wordpress cron.  The cache will last for up to 120 seconds.  This means the first user to visit for example your main page of your Wordpress it will be served by PHP.  The subsequent requests for up to 120 seconds will be served from the Litespeed cache and not use PHP.  As a result of this you’ll utilize less resources meaning you’ll be able to handle significantly more traffic.  To illustrate this I’ve installed a default Wordpress hello world installation on a regular shared web hosting server of ours.  We’ll perform 20 concurrent requests and a total of 1000 requests.

In the first benchmark we’re testing PHP 5.5 with absolutely no caching being utilized.

[plain] Time taken for tests:   183.143 seconds Complete requests:      1000 Failed requests:        0 Write errors:           0 Total transferred:      9079000 bytes HTML transferred:       8848000 bytes Requests per second:    5.46 [#/sec] (mean) Time per request:       3662.853 [ms] (mean) Time per request:       183.143 [ms] (mean, across all concurrent requests) [/plain]

What this means is we were able to handle 5.46 requests a second.  This would be pretty typical of a shared web hosting account.  We were limited by our CPU allocation of the web hosting plan.

Here is the same test with Litespeed page caching enabled:

[plain] Time taken for tests:   4.845 seconds Complete requests:      1000 Failed requests:        0 Write errors:           0 Total transferred:      9124218 bytes HTML transferred:       8848000 bytes Requests per second:    206.39 [#/sec] (mean) Time per request:       96.902 [ms] (mean) Time per request:       4.845 [ms] (mean, across all concurrent requests) Transfer rate:          1839.05 [Kbytes/sec] received [/plain]

This is a substantial difference we were able to serve 206.39 requests a second.  We’re now serving as much traffic as a dedicated server could that does not utilize caching.  This was however at just a concurrency of 20.  Our Litespeed cache is capable of significantly more than that.  Here is our test with 500 concurrency:

[plain] Time taken for tests:   2.717 seconds Complete requests:      5000 Failed requests:        0 Write errors:           0 Total transferred:      45625000 bytes HTML transferred:       44240000 bytes Requests per second:    1839.98 [#/sec] (mean) Time per request:       271.742 [ms] (mean) Time per request:       0.543 [ms] (mean, across all concurrent requests) Transfer rate:          16396.30 [Kbytes/sec] received [/plain]

We’re now able to serve up to 1839.98 requests a second.  If you were ever featured on the front page of a major news paper or even on a site like reddit with Litespeed caching you could handle that.  You wouldn’t lose out on that valuable traffic nor have unhappy visitors about how slow your page is.  This amount of traffic without the Litespeed cache would require multiple servers.

Simply put, enabling Litespeed cache on your Wordpress installations could result in a 33599% increase in speed. That’s approximately 337 times faster than a default Wordpress installation without Litespeed cache

If you’re not utilizing Wordpress many of the same techniques could be applied to other content management or blog platforms like Joomla and Drupal.  There also exists plugins for applications including the XenForo forum software that will allow you to handle more traffic.

Now that you have seen the results do not hesitant to enable this great feature.  If you have any questions do not hesitate to contact our support department.

Ready to get started? Build your site from
$2.24/mo
GET STARTED NOW