View Full Version : vB seo + litespeed cache
NiteWave
03-21-2011, 10:40 PM
We've enable litespeed cache on a living vB seo site successfully, the load dropped a lot during peak time, response has become faster.
vBulletin 4.1.2
vBSEO 3.6.0
litespeed 4.0.20
1. the cache plugin for vBulletin 3/4
<?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>
<version>1.0</version>
<url />
<versioncheckurl />
<dependencies>
</dependencies>
<codes>
</codes>
<templates>
</templates>
<plugins>
<plugin active="1" executionorder="1">
<title>Unset session id for guest users</title>
<hookname>global_start</hookname>
<phpcode><![CDATA[if($vbulletin->userinfo['userid'] <= 0)
{
$vbulletin->session->vars['sessionurl'] = '';
$vbulletin->session->vars['sessionurl_q'] = '';
}]]></phpcode>
</plugin>
<plugin active="1" executionorder="1">
<title>SET COOKIE FOR LOGGED IN USERS</title>
<hookname>login_verify_success</hookname>
<phpcode><![CDATA[if ($send_cookies AND $cookieuser)
{
// Cookie user
vbsetcookie('imloggedin', 'yes', true, true, true);
}
else
{
// Not permanent
vbsetcookie('imloggedin', 'yes', false, true, true);
}]]></phpcode>
</plugin>
<plugin active="1" executionorder="1">
<title>Send X-LiteSpeed-Cache-Control header for logged in users</title>
<hookname>style_fetch</hookname>
<phpcode><![CDATA[// Do not cache logged in user pages
if ( $vbulletin->userinfo['userid'] )
{
header('X-LiteSpeed-Cache-Control: no-cache');
};]]></phpcode>
</plugin>
</plugins>
<phrases>
</phrases>
<options>
</options>
<helptopics>
</helptopics>
<cronentries>
</cronentries>
<faqentries>
</faqentries>
</product>
save above code as litespeed_cache.xml, and using
vBulletin Admin Control Panel(/admincp)->
Plugins & Products->
Add/Import Product
to import above .xml.
2.rewrite rule in vBulletin's home directory .htaccess
#VBSEO -- original vbseo rules
....
RewriteRule ^(.+)$ vbseo.php [L,QSA]
===>
RewriteRule ^(.+)$ vbseo.php [QSA]
#rules for litespeed cache:
RewriteCond %{HTTP_COOKIE} !vbseo_loggedin=yes
RewriteCond %{HTTP_COOKIE} !bb_userid=
RewriteCond %{HTTP_COOKIE} !bb_password=
#RewriteCond %{ORG_REQ_URI} ^/(index\.php|)$
RewriteCond %{REQUEST_METHOD} ^HEAD|GET$
RewriteCond %{QUERY_STRING} ^$
RewriteRule (.*) - [L,E=Cache-Control:max-age=60]
note:
1. in fact nothing new here, just put all pieces together to make it simple
2. the vBulletin plugin is based on the vB plugin for varnish as we always mentioned in past posts/blog.
Boosting vBulletin Performance with Advanced Caching (http://www.vbulletin.com/forum/entry.php/2440-vB4Mance-Part-5-Expert-Level-Boosting-vBulletin-Performance-with-Advanced-Caching),the attached file product-boostv1.xml
bhanuprasad1981
03-25-2011, 02:00 PM
bit confusing for me , i created and installed plugin as mentioned, but struck at .htaccess i presently have this what should be there instead of it :-
# Comment the following line (add '#' at the beginning)
# to disable mod_rewrite functions.
# Please note: you still need to disable the hack in
# the vBSEO control panel to stop url rewrites.
RewriteEngine On
# Some servers require the Rewritebase directive to be
# enabled (remove '#' at the beginning to activate)
# Please note: when enabled, you must include the path
# to your root vB folder (i.e. RewriteBase /forums/)
#RewriteBase /
RewriteCond %{HTTP_HOST} ^mysite.org$ [OR]
RewriteCond %{HTTP_HOST} ^www.mysite.org$
RewriteRule ^/?$ "http\:\/\/www\.mysite\.org\/index\.php" [R=301,L]
RewriteRule ^((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
RewriteCond %{REQUEST_URI} !(admincp/|modcp/|cron|vbseo_sitemap)
RewriteRule ^((archive/)?(.*\.php(/.*)?))$ vbseo.php [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/(admincp|modcp|clientscript|cpstyles|images)/
RewriteRule ^(.+)$ vbseo.php [L,QSA]
just quote me what has to be there in that .htaccess file
thanks.
NiteWave
03-25-2011, 09:57 PM
the last line of your rewrite rule is
RewriteRule ^(.+)$ vbseo.php [L,QSA]
remove the "L", change to
RewriteRule ^(.+)$ vbseo.php [QSA]
then add those rules follow
#rules for litespeed cache:
in my first post to your .htaccess
As I understand we need 2cpu license to support that, correct?
NiteWave
04-01-2011, 03:58 AM
yes.
http://www.litespeedtech.com/litespeed-web-server-editions.html
see "Disk cache (mod_cache) Support"
I tried these settings without any luck. Only difference is I'm using 3.8.
NiteWave
05-24-2011, 06:44 PM
vB 3.8 should be ok.
to be sure the cookie name is same as previous post:
RewriteCond %{HTTP_COOKIE} !bb_userid=
RewriteCond %{HTTP_COOKIE} !bb_password=
it's customizable by vB admin. for example, if yours is myvb_userid, change above bb_ to myvb_
ihstiv
07-14-2011, 11:23 AM
Thanks for this concise tutorial - I was able to implement it successfully in my forum.
I do have a question about the htaccess rule updates, specifically, I'm wondering why we remove the 'L' from [L,QSA] - I have a few different rewrite rules that include the vbseo.php file, and I want to make sure that I should remove the 'L' from all of them, including here?
RewriteRule content/([0-9]+)-([^/])+ forum/vbseo.php?vbseourl=content.php&r=$1 [L,R]
I think the 'L' means, 'Last rule - stop processing', which makes sense so that it stops once a match is made, instead of continuing to rewrite if another match is made further down the list of rules.
I don't understand how this bit plays into the caching feature.
Can anyone enlighten me on this part a little?
NiteWave
07-14-2011, 07:31 PM
good question - there is a better solution. and we've been just aware that not a long time ago.
I'd publish the new suggested rewrite rules by this chance:
usually there exists such a rewriterule in .htaccess of document root:
RewriteCond %{HTTP_HOST} !^www\.mysite\.org$
RewriteRule ^(.*)$ http://www.mysite.org/$1 [R=301,L]
just insert the new cache related rules after above rules:
#rules for litespeed cache:
RewriteCond %{HTTP_COOKIE} !vbseo_loggedin=yes
RewriteCond %{HTTP_COOKIE} !bb_userid=
RewriteCond %{HTTP_COOKIE} !bb_password=
#RewriteCond %{ORG_REQ_URI} ^/(index\.php|)$
RewriteCond %{REQUEST_METHOD} ^HEAD|GET$
RewriteCond %{QUERY_STRING} ^$
RewriteRule (.*) - [E=Cache-Control:max-age=60]
and leave the rest rewrite rules there without change!
the typical ones are:
RewriteRule ^((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
RewriteCond %{REQUEST_URI} !(admincp/|modcp/|cron|vbseo_sitemap)
RewriteRule ^((archive/)?(.*\.php(/.*)?))$ vbseo.php [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/(admincp|modcp|clientscript|cpstyles|images)/
RewriteRule ^(.+)$ vbseo.php [L,QSA]
this make lsws cache function easier to use and less chance to make mistakes.
ihstiv
07-15-2011, 10:25 AM
Ok - thanks for the update!
to confirm, the latest approach is to leave the 'L' intact in the rule(s) containing 'vbseo.php' - instead of removing it as recommended previously.
So use this:
RewriteRule ^(.+)$ vbseo.php [L,QSA]
..and not this:
RewriteRule ^(.+)$ vbseo.php [QSA]
correct?
NiteWave
07-15-2011, 10:32 AM
you are right.
Not only that rule, but also all other rewrite rules, leave them "as is", without change. for complex rewrite rules, it's very tricky and risky to change anything.
ihstiv
07-15-2011, 10:56 AM
Ok - thanks. I'll make the necessary changes.
two more questions:
1. can you help me understand this line:
#RewriteCond %{ORG_REQ_URI} ^/(index\.php|)$
..and why it is commented out?
2. is there a way to use the 'private cache' feature in lsws for vbulletin/vbseo logged in members?
NiteWave
07-15-2011, 11:16 AM
1.please remove it:
#RewriteCond %{ORG_REQ_URI} ^/(index\.php|)$
it's for test purpose: enable cache for homepage only.
if test pass, comment it out.
2.we've no chance to test "private cache" with vB/vbseo yet.
ihstiv
07-15-2011, 01:28 PM
usually there exists such a rewriterule in .htaccess of document root:
RewriteCond %{HTTP_HOST} !^www\.mysite\.org$
RewriteRule ^(.*)$ http://www.mysite.org/$1 [R=301,L]
just insert the new cache related rules after above rules:
#rules for litespeed cache:
RewriteCond %{HTTP_COOKIE} !vbseo_loggedin=yes
RewriteCond %{HTTP_COOKIE} !bb_userid=
RewriteCond %{HTTP_COOKIE} !bb_password=
#RewriteCond %{ORG_REQ_URI} ^/(index\.php|)$
RewriteCond %{REQUEST_METHOD} ^HEAD|GET$
RewriteCond %{QUERY_STRING} ^$
RewriteRule (.*) - [E=Cache-Control:max-age=60]
[/CODE]
I've found that moving the lsws rules to the top of the htaccess file tends to cause problems, including 404 errors. The only thing that solves the errors is to move the lsws rules below all existing VBSEO RewriteCond and RewriteRule statements.
RedirectMatch and other statements can go below it w/o problem.
Knowing this, does it still make sense to leave this line as-is:
RewriteRule ^(.+)$ vbseo.php [L,QSA]
..or would it be better to change it to this?
RewriteRule ^(.+)$ vbseo.php [QSA]
Cheers
freeballt
07-15-2011, 01:39 PM
Knowing this, does it still make sense to leave this line as-is:
RewriteRule ^(.+)$ vbseo.php [L,QSA]
..or would it be better to change it to this?
RewriteRule ^(.+)$ vbseo.php [QSA]
Cheers
I'm wondering the same thing.
I also tested this on 3.8.4 and it doesn't seem to execute this: "header('X-LiteSpeed-Cache-Control: no-cache');"
Many of my users are complaining about being logged out, and when I look at it in firebug it doesn't seem to have no-cache in response.
I also had to disable the plugin because if a user is IP banned, it will show an IP banned message to other users.
NiteWave
07-15-2011, 07:27 PM
Many of my users are complaining about being logged out, and when I look at it in firebug it doesn't seem to have no-cache in response.
this header "X-LiteSpeed-Cache-Control: no-cache" is used between litespeed processs and lsphp5 process, will not show in response header, so not seen by firebug
I've found that moving the lsws rules to the top of the htaccess file tends to cause problems, including 404 errors. The only thing that solves the errors is to move the lsws rules below all existing VBSEO RewriteCond and RewriteRule statements.
can you test homepage only(as discussed before), or another page, the rule is like:
RewriteCond %{ORG_REQ_URI} ^/test-this-page/)$
and clear cache folder first. only after succeeded for 1 page, then move on.
I've found that moving the lsws rules to the top of the htaccess file tends to cause problems, including 404 errors. The only thing that solves the errors is to move the lsws rules below all existing VBSEO RewriteCond and RewriteRule statements.
I'm having the same issue - if I move the rules to the bottom nothing gets cached though.
Has anyone figured this out?
NiteWave
09-12-2011, 05:54 PM
moving the rules to top is recommended. if not working, you can post your rules here to see if any change to improve them.
I was using your rewrite rules from the first post right after the
RewriteCond %{HTTP_HOST} !^site\.net
RewriteRule (.*) http://site.net/$1 [L,R=301]
I wonder if this has something to do with gzip being enabled?
I did a quick test on another one of my sites with the default vbseo rules.
Configuring things with the setup in post 1 of this thread returns a 404 error on every page. (L removed from last vbseo rule and included in last cache rule)
Removing the L in the last cache rule and replacing in the last vbseo rule as in post 9 does not result in errors, but it does not appear anything is cached. Total cache hits and cache hits/sec remain at 0 when viewing real-time statistics.
NiteWave
11-29-2011, 05:47 PM
you can try cache 1 page first -- for example phpinfo() page, to get it working.
you can do it in rewriterule.
you can try cache 1 page first -- for example phpinfo() page, to get it working.
you can do it in rewriterule.
I tried that - still nothing.
This is what my rules look like:
RewriteEngine On
Header unset ETag
FileETag None
ExpiresActive on
ExpiresByType image/jpg "access plus 1 months"
ExpiresByType image/gif "access plus 1 months"
ExpiresByType image/jpeg "access plus 1 months"
ExpiresByType image/png "access plus 1 months"
RewriteCond %{HTTP_HOST} !^nikonites\.com
RewriteRule (.*) http://nikonites.com/$1 [R=301,L]
#rules for litespeed cache:
RewriteCond %{HTTP_COOKIE} !vbseo_loggedin=yes
RewriteCond %{HTTP_COOKIE} !bb_userid=
RewriteCond %{HTTP_COOKIE} !bb_password=
#RewriteCond %{ORG_REQ_URI} ^/(index\.php|)$
RewriteCond %{REQUEST_METHOD} ^HEAD|GET$
RewriteCond %{QUERY_STRING} ^$
RewriteRule (.*) - [E=Cache-Control:max-age=120]
RewriteRule ^((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
RewriteCond %{REQUEST_URI} !(admincp/|modcp/|cron|vbseo_sitemap|api\.php)
RewriteRule ^((archive/)?(.*\.php(/.*)?))$ vbseo.php [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/(admincp|modcp|clientscript|cpstyles|images|api\.p hp)/
RewriteRule ^(.+)$ vbseo.php [L,QSA]
NiteWave
11-30-2011, 12:35 AM
I can take a look at your server if you give the access
Home Alone
12-11-2011, 07:37 AM
Many of my users are complaining about being logged out, and when I look at it in firebug it doesn't seem to have no-cache in response.
I also had to disable the plugin because if a user is IP banned, it will show an IP banned message to other users.
I'm also experiencing these two problems. Did you ever resolve it?
NiteWave
12-11-2011, 08:51 AM
I think the "issue" is because guest cache not set up correctly somewhere.
We've enabled vb seo cache for quite a few users and not experienced this issue so far.
Home Alone
12-11-2011, 10:36 AM
I think the "issue" is because guest cache not set up correctly somewhere.
We've enabled vb seo cache for quite a few users and not experienced this issue so far.
This is my .htaccess file:
RewriteCond %{HTTP_HOST} !^www\.domain\.com$
RewriteRule (.*)$ http://www.domain.com/$1 [R=301,L]
#rules for litespeed cache:
RewriteCond %{HTTP_COOKIE} !vbseo_loggedin=yes
RewriteCond %{HTTP_COOKIE} !bb_userid=
RewriteCond %{HTTP_COOKIE} !bb_password=
#RewriteCond %{ORG_REQ_URI} ^/(index\.php|)$
RewriteCond %{REQUEST_METHOD} ^HEAD|GET$
RewriteCond %{QUERY_STRING} ^$
RewriteRule (.*) - [E=Cache-Control:max-age=60]
RewriteRule ^view_(.*).htm$ view.php?pg=$1
RewriteRule ^((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
RewriteCond %{REQUEST_URI} !(admincp/|modcp/|cron|showwiki)
RewriteRule ^((archive/)?(.*\.php(/.*)?)?)$ vbseo.php [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^(admincp|modcp|clientscript|cpstyles|images|show wiki)/
RewriteRule ^(.+)$ vbseo.php [QSA]
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^vb/?$ "http\:\/\/www\.domain\.com" [R=301,L]
php_flag display_errors off
RewriteCond %{HTTP_REFERER} !^http://domain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://domain.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.domain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.domain.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://games.espn.go.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://games.espn.go.com$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F]
This is my 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)120
NiteWave
12-11-2011, 07:32 PM
the rules looks fine.
RewriteCond %{HTTP_COOKIE} !bb_userid=
RewriteCond %{HTTP_COOKIE} !bb_password=
since bb_userid and bb_password is customizable by vB, to be sure you're using the same cookie name - if you're using vb_userid and vb_passwords etc, please change above rules as well.
Home Alone
12-16-2011, 12:01 PM
the rules looks fine.
RewriteCond %{HTTP_COOKIE} !bb_userid=
RewriteCond %{HTTP_COOKIE} !bb_password=
since bb_userid and bb_password is customizable by vB, to be sure you're using the same cookie name - if you're using vb_userid and vb_passwords etc, please change above rules as well.
I'm using the default values.
TechGuy
12-27-2011, 02:02 PM
What settings did you guys use for Cache Policy, etc? I've installed the plugin, rewrite rules, etc... but still no caching. :(
webizen
12-28-2011, 04:58 PM
for guest caching, the following policy can be used. make sure you have cache storage settings defined.
Enable Cache No
Cache Expire Time (seconds) Not Set
Cache Request with Query String Not Set
Cache Request with Cookie Not Set
Cache Response with Cookie Not Set
Ignore Request Cache-Control Not Set
Ignore Response Cache-Control Not Set
Enable Private Cache Not Set
Private Cache Expire Time (seconds) Not Set
To troubleshoot, enable rewrite logging.
freeballt
03-03-2012, 11:31 AM
I think the "issue" is because guest cache not set up correctly somewhere.
We've enabled vb seo cache for quite a few users and not experienced this issue so far.
What stops this plugin for displaying a cache with the banned message to someone who isn't banned?
semprot
04-17-2012, 09:10 AM
I used vbulletin too, and litespeed with 2 cpu license, can 2 cpu license do caching?
I don't use vbseo, do i need to use htaccess on first post too?
webizen
04-17-2012, 09:59 AM
2-CPU license supports caching.
yes, for vb, you still need the plugin and rewrite rules in .htaccess as shown in the 1st post.
semprot
04-17-2012, 10:26 AM
2-CPU license supports caching.
yes, for vb, you still need the plugin and rewrite rules in .htaccess as shown in the 1st post.thanks i've tried it.. is there any way to test whether the litespeed caching works?
webizen
04-17-2012, 12:56 PM
LiteSpeed outputs a response header “X-LiteSpeed-Cache: hit” if a request is served from cache.
desifunz
05-06-2012, 09:48 AM
can i use this cache option for my litespeed vps licence ? please guide me about this ,
NiteWave
05-06-2012, 08:10 PM
No, cache need at least 2-CPU license.
Yogesh Sarkar
06-09-2012, 06:14 AM
Anyone using this plugin with vb 4.2 and vbseo 3.6? If yes, then does it work properly?
Chris
06-13-2012, 07:39 AM
vBseo and 4.2 don't work fluidly out of the box from what I understand.
Yogesh Sarkar
06-13-2012, 07:42 AM
Not really, it works alright. Have been running it for almost couple of weeks now.
Chris
06-13-2012, 07:51 AM
I'm running it on 3.8 just fine.
I don't see where 4.2 would run into any issues.
eagle eyes
10-05-2012, 01:16 PM
Can i see the live performance of vb litespeed cache?
What are the negatives? Guests can't see the updated pages?
NiteWave
10-05-2012, 07:56 PM
What are the negatives? Guests can't see the updated pages?
yes. if you cache 2 minutes, then guest user may not read updated page in recent 2 minutes. usually it's acceptable.