Super Charge WordPress With Litespeed Cache

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:

<IfModule LiteSpeed>
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]
</IfModule>

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.

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)

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:

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

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:

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

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.

This entry was posted in General and tagged , , . Bookmark the permalink.

21 Responses to Super Charge WordPress With Litespeed Cache

  1. James says:

    Thanks, it helps a lot

  2. Dmitri says:

    This is a very interesting option. Looks like the optimizations previously available to VPS/dedicated clients only, now available for shared hosting.

    But besides speed, I have a number of questions, like:

    – how to configure this properly e.g. for Drupal and phpBB (I have only one small WP site)?
    – how well this solution will work for frequently user-updated content, e.g. comments and especially forums (where people may start double-posting seeing cached page without their response)?
    – why Xenforo needs a plugin? probably server-wide cache is unable to “notice” and handle new forum posts immediately?
    – is there a forum or some other place, where users (and maybe developers) discuss this feature, post their experience and answer questions?

    I can go on, but these are primary ones to me.

  3. Tony Baird says:

    – how to configure this properly e.g. for Drupal and phpBB (I have only one small WP site)?

    It’ll work for all applications it’s just a matter of what you can and cannot cache. So this line:

    RewriteCond %{REQUEST_URI} !^(wp-admin|wp-login.php|wp-cron.php)

    It told it to not cache the wordpress admin backend for example. You would just in Drupal’s case add it’s equivalent admin url.

    – how well this solution will work for frequently user-updated content, e.g. comments and especially forums (where people may start double-posting seeing cached page without their response)?

    This is where plugins come in handy to tell the cache to clear.

    – why Xenforo needs a plugin? probably server-wide cache is unable to “notice” and handle new forum posts immediately?

    You’re correct with the plugin it can tell the web server to purge pages that need to immediately expire.

    – is there a forum or some other place, where users (and maybe developers) discuss this feature, post their experience and answer questions?

    There is our forum http://forums.hawkhost.com/ and there is also the litepeed forum: https://www.litespeedtech.com/support/forum/

  4. obat wasir herbal says:

    want to try…

  5. Jerry says:

    Thanks, just apply this code to .htaccess file on my site http://www.hostot.net and it’s increase the speed too much, so fast loading.

    Thanksssssssssssss

  6. Larry says:

    I ran into an odd issue where I couldn’t login, everytime I tried it would just come back to the login page (not giving a failed/invalid password)

    I had to modify this line:
    RewriteCond %{REQUEST_URI} !^(wp-admin|wp-login.php|wp-cron.php)

    to this so it had the leading / :
    RewriteCond %{REQUEST_URI} !^/(wp-admin|wp-login.php|wp-cron.php)

    https://www.litespeedtech.com/support/forum/threads/solved-wordpress-users-cant-login-when-litespeed-cache-is-active.9922/

  7. ngoc to says:

    Thanks for the tips, I already put these line of codes onto my .htaccess file, but I am wondering should I disable the page cache option of W3TC, or leaving it on would work just fine along with litespeed cache?

    Please help, thanks a lot.

  8. motorninja250.com says:

    thanks for share i like it..

  9. George says:

    Very helpful this article! I set myself in my file httaces! Thanks admin!

  10. Ivan says:

    Hello,
    How to config with W3TC, should I disable the page cache, minify, DB, object cache?
    Any tutorial settings with W3TC?
    Thanks

  11. Filme online 2016 says:

    Very helpful this article! I set myself in my file httaces! Thanks admin!

  12. Rizal Bakrie says:

    This is interesting topic with good explanation. Very helpful, i’ll try on my htaccess. Thanks for share mate, regards.

  13. Rezza says:

    What is the same function LiteSpeed plugins cache?

  14. Lonny Ackah says:

    Some really excellent content on this website , thanks for contribution.

  15. Dan says:

    I’ve been using the litespeed cache plugin and find I’m getting far better results with w3 total cache testing on kingdom tools

  16. Summase says:

    How to exclude homepage from the LiteSpeed cache plugin?

  17. David says:

    Can someone explain what Litespeed Cache plugin does differently than W3TC? What makes it slightly better?

  18. Rajul sahu says:

    Thanks for help a lot.

  19. GMK Group says:

    i have using this on my hosting, it help to get fast speed than general hosting

  20. Dexuat says:

    Thanks, just apply this code to .htaccess file and install plugin litespeed cache in wordpress on my site and it’s increase the speed too much, so fast loading.

  21. elizon says:

    host speed is quite fast but around 19h-22pm in vietnam is very slow

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.