LSCache + vBSEO (Guest Cache)

LSCache can be setup for vBSEO with vB cache plugin for guest cache.

vBulletin 3/4
vBSEO 3.6.0
LiteSpeed WebServer 4.0+ (supports public cache)

1. Save the following Cache plugin for vBulletin 3/4 to a file say litespeed_cache.xml

<?xml version="1.0" encoding="ISO-8859-1"?>

<product productid="lswscache" active="1">
        <title>Litespeed Caching</title>
        <description>settings to make Litespeed page cache working right</description>
        <url />
        <versioncheckurl />
                <plugin active="1" executionorder="1">
                        <title>Unset session id for guest users</title>
                        <phpcode><![CDATA[if($vbulletin->userinfo['userid'] <= 0)
$vbulletin->session->vars['sessionurl']  = '';
$vbulletin->session->vars['sessionurl_q']  = '';
                <plugin active="1" executionorder="1">
                        <title>SET COOKIE FOR LOGGED IN USERS</title>
                        <phpcode><![CDATA[if ($send_cookies AND $cookieuser)
// Cookie user
vbsetcookie('imloggedin', 'yes', true, true, true);
// Not permanent
vbsetcookie('imloggedin', 'yes', false, true, true);
                <plugin active="1" executionorder="1">
                        <title>Send X-LiteSpeed-Cache-Control header for logged in users</title>
                        <phpcode><![CDATA[// Do not cache logged in user pages
if ( $vbulletin->userinfo['userid'] )
        header('X-LiteSpeed-Cache-Control: no-cache');

2. Add the xml in 1. to vBulletin

 Log into Admin Console Panel (http://site/forum/admincp)
    Plugins & Products => Add/Import Product)

3. Modify rewrite rules in .htaccess

Rewrite Rules: on the very beginning, maybe just after

RewriteEngine On


#rules for litespeed cache: begin
RewriteCond %{HTTP_COOKIE} !vbseo_loggedin=yes
RewriteCond %{HTTP_COOKIE} !bbuserid=
RewriteCond %{HTTP_COOKIE} !bbpassword=
#RewriteCond %{ORG_REQ_URI} ^/(index\.php|)$
RewriteCond %{QUERY_STRING} ^$
RewriteRule (.*) - [E=Cache-Control:max-age=60]
#rules for litespeed cache: end

There is no need to change any other rewrite rules that come from vBSEO or other sources.

4. Enable and Set up Cache Policy in LSWS

In LiteSpeed (v4.1.2 or later) Admin CP → Configuration → Server → Cache

Storage Path: /diskcache
Max Object Size: 128K

Cache Policy
Enable Cache:    No
Cache Expire Time (seconds):    Not Set
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:    No
Private Cache Expire Time (seconds):    
Do-Not-Cache URL(s):


  1. Cache storage can be set to /dev/shm/diskcache to avoid disk I/O wait if enough memory can be spared.
  2. Cache resource with size less than 128KB.
  3. your vB's coookie name may vary, for example my_userid instead of bbuserid, depends on your vB configuration.
  4. For cached request, “X-LiteSpeed-Cache: hit” response header should be seen. IOW, if no such entry in the response header, the response is not cached by LSWS.
*/10 * * * * find /diskcache -type f -mmin +10 –delete

Note: This cron job cleans up stale cache storage every 10 minutes.

Add entries to /etc/rc.local

   echo "mkdir /diskcache && chmod nobody.lsadm" >> /etc/rc.local
   echo "/diskcache && chmod 770 /diskcache" >> /etc/rc.local

Note: this is to make sure cache directory gets created when server is booted up.

  • Admin
  • Last modified: 2017/01/03 21:39
  • by Michael Alegre