1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XenForo LiteSpeed Cache 1.1.0 Release

Massively reduce your database queries when running LiteSpeed Web Server.

  1. Slavik
    Compatible XF Versions:
    • 1.2
    Additional Requirements:
    Requires LiteSpeed Enterprise Web Server 2 CPU license or higher - https://store.litespeedtech.com/store/cart.php
    Even on the busiest of forums, the majority of queries and server load often come from guest users browsing the forum. This can be even more evident if you have sudden flash visits to your site following some sort of promotion or event.

    This addon works in conjunction with LiteSpeed's Enterprise Web Server to leverage the caching mechanism in LiteSpeed to create a 60 second rolling window of all pages accessed on your site for guest users.

    This includes most notably:

    The Forum Homepage (/index)
    Node pages (/forums)
    Threads (/threads)
    Thread Pages (/threads/page-2 etc)
    Member profiles (/members)

    Whenever a page is first loaded, its output is saved in the cache, and all subsequent guest visits to this page within the 60 second window are served from the cache, rather than by generating a new page load (and thus the queries are eliminated). After 60 seconds, the cached file is removed, and the process repeats. This allows for an active forum to maintain a very active appearance to guests, even though the page they are viewing could be upto 59 seconds old.

    Importantly, logged in users are not subject to this caching, and the forum will work normally for logged in users!

    This is a small 5 minute test run on a very active (3000 online users) forum with approximately half of its users being guests. The 2 black lines represent when the addon was enabled and then disabled.

    test.png

    Installation

    1) Install the addon (Note, this will log all your users out, this is intended and required)

    2) Run the following commands in SSH

    Code:
     
    mkdir /tmp/diskcache
    chown nobody:nobody /tmp/diskcache
    chmod 777 /tmp/diskcache
    
    3) In LiteSpeed set your cache policies, this can be done per-vhost or on a server-wide level.

    Code:
    Storage Path: /tmp/diskcache
    Max Object Size: 1024000
    Enable Cache: No (this is correct, we will use .htaccess later to override this)
    Cache Expire Time: 120
    Cache Request with Query String: Yes
    Cache Request with Cookie: Yes
    Cache Response with Cookie: Yes
    Ignore Request Cache-Control: Yes
    Ignore Response Cache-Control: Yes
    Enable Private Cache: Not Set
    Private Cache Expire Time: Not Set
    
    4) Add the following to the top of your .htaccess (if you have .htaccess import redirects, place these *after* the redirects)

    Code:
    <IfModule litespeed>
    RewriteEngine On
    RewriteCond %{REQUEST_METHOD} ^HEAD|GET$
    RewriteCond %{HTTP_COOKIE} !skipPageCache
    RewriteRule .* - [E=Cache-Control:max-age=60]
    </IfModule>
    
    5) Optionally, add a clean up cron job to remove old cached files more than 2 minutes old.

    Code:
    */10 * * * * root find /tmp/diskcache -type f -mmin +2 -delete 2>/dev/null
    Important
    To disable this addon, you *must* remove or comment out the .htaccess rewrites also. Disabling the addon in ACP will only cause other issues.

    Credits
    Big thanks to extralicense for building the addon :)
    Gladius, lsmichael, Alfa1 and 11 others like this.

Recent Updates

  1. 1.1.0 Release
  2. 1.0.0 Release

Recent Reviews

  1. Mike Fara
    Mike Fara
    5/5,
    Version: 1.1.0 Release
    We must see how it does... so far so good...
  2. The Sandman
    The Sandman
    5/5,
    Version: 1.1.0 Release
    Works great and comes with excellent support!
  3. Mike Edge
    Mike Edge
    5/5,
    Version: 1.1.0 Release
    Outstanding! We are the 1st hosting solutions provider to offer this on all our client servers. I also use it on my personal server for my xF communities.. P.S. Slavik has cooties! :)