|
|

03-21-2011, 10:40 PM
|
|
LiteSpeed Staff
|
|
Join Date: Sep 2009
Posts: 2,218
|
|
vB seo + litespeed cache
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
Code:
<?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,the attached file product-boostv1.xml
Last edited by NiteWave; 03-21-2011 at 10:51 PM..
|

03-25-2011, 02:00 PM
|
|
Senior Member
|
|
Join Date: Apr 2009
Posts: 160
|
|
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 :-
Code:
# 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.
|

03-25-2011, 09:57 PM
|
|
LiteSpeed Staff
|
|
Join Date: Sep 2009
Posts: 2,218
|
|
|
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
|

04-01-2011, 03:19 AM
|
|
Senior Member
|
|
Join Date: Jan 2008
Posts: 65
|
|
|
As I understand we need 2cpu license to support that, correct?
|

04-01-2011, 03:58 AM
|
|
LiteSpeed Staff
|
|
Join Date: Sep 2009
Posts: 2,218
|
|
|
|

05-24-2011, 12:20 PM
|
|
New Member
|
|
Join Date: May 2011
Posts: 9
|
|
|
I tried these settings without any luck. Only difference is I'm using 3.8.
|

05-24-2011, 06:44 PM
|
|
LiteSpeed Staff
|
|
Join Date: Sep 2009
Posts: 2,218
|
|
|
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_
|

07-14-2011, 11:23 AM
|
|
New Member
|
|
Join Date: Jul 2011
Posts: 6
|
|
|
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?
|

07-14-2011, 07:31 PM
|
|
LiteSpeed Staff
|
|
Join Date: Sep 2009
Posts: 2,218
|
|
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:
Code:
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:
Code:
#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:
Code:
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.
Last edited by NiteWave; 07-14-2011 at 07:34 PM..
|

07-15-2011, 10:25 AM
|
|
New Member
|
|
Join Date: Jul 2011
Posts: 6
|
|
|
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?
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 08:49 PM.
|
|