vBulletin - Litespeed cache for guests and Unixy Varnish plugin for all?

asabet

Active Member
#1
I'm currently using the Unixy Varnish plugin for Litespeed, and it works great for caching static files (png, css, etc), but as far as I can tell there is no way to set a different dynamic TTL for members vs guests. So I keep dynamic TTL set to 0 so as to keep the content fresh and current for my members.

I read that Litespeed cache can be implemented for guests only. Can I use it alongside the Unixy Varnish plugin? I tried doing so by following the directions here: http://blog.litespeedtech.com/2011/01/28/speed-up-vbulletin-sites-through-litespeed-built-in-cache/

However, I couldn't tell if Litespeed cache was doing anything. One point of confusion in following the instructions was that I don't know if I am using a natively configured vhost vs imported Apache vhost. I have no idea what a vhost is or how to figure out what mine is.
 

Michael

Well-Known Member
Staff member
#2
Hi @asabet,

A vhost is a virtual host. The easiest way to think of it may be that a virtual host is one site on your server. If you are using Apache configurations (httpd.conf, .htaccess, etc.), then you are using Apache vhosts. If you configured your virtual hosts in our WebAdmin GUI, then you are using natively configured vhosts. I'm assuming you're using Apache vhosts (otherwise you probably would have noticed the word "vhost" in our WebAdmin).

Technically, you could use LSCache alongside Varnish, but it would be rather silly (in my view), since they do mostly the same thing. There's no reason to set up both caches.

I can't give any feedback on setting up Unixy's plugin. I don't think anyone here is familiar with it. If you have questions about caching dynamic content with Unixy's plugin, you should probably contact Unixy. (Also, it probably doesn't make sense to cache static content when you're using LSWS, since LSWS serves static content so quickly. Since Apache is slower, it can make sense in that situation, but it doesn't make sense when using LSWS.)

Cheers,

Michael
 

semprot

Well-Known Member
#3
I own vbulletin too.
If you want caching features (including vbulletin guest full cache), i suggest you to check dragonbyte vb optimise plugin (the pro version).
It just works :)
 

asabet

Active Member
#4
...(Also, it probably doesn't make sense to cache static content when you're using LSWS, since LSWS serves static content so quickly. Since Apache is slower, it can make sense in that situation, but it doesn't make sense when using LSWS.)
Hi Michael, thanks for your reply. If I pay the $150 installation for LS cache, will that include doing any redirects needed on my 5 vbulletin forums, and is there anyway to configure Litespeed cache to ignore/blacklist my javascript ads (Adsense and Amazon CPM ads)?
 

NiteWave

Administrator
#5
>will that include doing any redirects needed on my 5 vbulletin forums
can you give more details ? in general redirect is easy to do in .htacess

>anyway to configure Litespeed cache to ignore/blacklist my javascript ads (Adsense and Amazon CPM ads)?
for javascript ads, javascript is in the cache but ads not in cache, so no need ignore/blacklist etc, the ads will work just fine, ads' content is not cached.
 

asabet

Active Member
#6
Technically, you could use LSCache alongside Varnish, but it would be rather silly (in my view), since they do mostly the same thing. There's no reason to set up both caches.
Update: I set them both up together, and the results are wonderful! As currently setup on my forum, LSCache caches everything (including dynamic content) for 2 minutes for guests and caches nothing at all for logged in members. Meanwhile the Varnish plugin caches static content for 2 hours for all and caches dynamic content for 8 seconds for logged in members (with no effects on guests). They just work beautifully together.
 

Michael

Well-Known Member
Staff member
#7
I stand corrected, I guess?

Why did you decide to cache logged in members' content through Varnish and not LSCache?

Also, I'd be interested in whether caching the static content makes a difference in performance. Theoretically, caching static content in front of LSWS shouldn't help performance (and might hinder overall performance) because LSWS serves static content so quickly. Caching static content for Apache makes a lot of sense because Varnish is faster than Apache. I believe, though, that Varnish is not faster than LSWS serving the static content itself. I'm definitely interested in your real world results with this.

Thanks for the feedback.

Michael
 

asabet

Active Member
#8
Why did you decide to cache logged in members' content through Varnish and not LSCache?
Is it possible to cache guest content for 2 minutes and logged in member content for 8 seconds using LScache alone? I guess one could argue that the 8 second member cache doesn't do anything, but I can say that LSWS + Varnish plugin made the forums noticeably faster than LSWS + no cache. I haven't tried LSWS + LSCache without Varnish yet.

One thing since I enabled LSCache for guests is that some members are reporting trouble staying logged in.

Edit: I'm seeing a lot of weirdness on the forums, actually. Style changes, login problems, etc. I guess you were right about not using LSCache and Varnish together!
 
Last edited:

Michael

Well-Known Member
Staff member
#9
Hard to say whether those are from using the two together or just one being set up improperly. Page caching is effective, but it's not easy. Time to start isolating which rules are causing the issues...
 

asabet

Active Member
#10
The Varnish plugin on its own causes no problems. These are the .htaccess rules I was using, adapted from these instructions with adjustments for the fact that my vBulletin is installed at at $DOCUMENT_ROOT not at $DOCUMENT_ROOT/forum:

Code:
## select which pages to cache
RewriteCond %{HTTP_COOKIE} !bbimloggedin=yes
RewriteCond %{HTTP_COOKIE} !bbuserid=
RewriteCond %{HTTP_COOKIE} !bbpassword=
RewriteCond %{REQUEST_METHOD} ^HEAD|GET$
RewriteCond %{QUERY_STRING} !s=[a-fA-F0-9]{32}
RewriteCond %{QUERY_STRING} !product=vbnexus
RewriteCond %{REQUEST_URI} !^(login|register|usercp|private|profile|cron|image)\.php$
RewriteCond %{REQUEST_URI} !^admincp
RewriteRule ^(.*\.php)?$ - [L,E=Cache-Control:max-age=120]
My understanding was that the product-boostv1.xml product would keep LSCache from affecting logged in members, but in actuality they experienced all kinds of weirdness.
 
#11
the rewriterule need minor change, please last 3 lines to
Code:
RewriteCond %{REQUEST_URI} !^/(login|register|usercp|private|profile|cron|image)\.php$
RewriteCond %{REQUEST_URI} !^/admincp
RewriteRule ^(.*\.php)?$ - [E=Cache-Control:max-age=120]
for product-boostv1.xml, we have put it on our wiki in another page: https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscache:vbseo
"1. Save the following Cache plugin for vBulletin 3/4 to a file say litespeed_cache.xml"

after you make lscache working, please try to disable "Unixy Varnish plugin", we guess there may be no performance loss.
 
Last edited by a moderator:

asabet

Active Member
#12
Thank you, I made those changes. Three more questions:

1) If I am using /dev/shm/diskcache do I still need a cronjob to delete, and if so is this right?

*/10 * * * * root find /dev/shm/diskcache -type f -mmin +8 -delete 2>/dev/null

2) Do permissions for /diskcache need to be 700 or 770? This article says 700, and this article says 770.

I currently have it set as 700, and my pages are getting cached as expected.

3) Do I need to add entries to /etc/rc.local ? This article says so, and this one doesn't mention. If so, is this right?

echo "mkdir /dev/shm/diskcache && chmod nobody.lsadm" >> /etc/rc.local
echo "/dev/shm/diskcache && chmod 700 /dev/shm/diskcache" >> /etc/rc.local
 

asabet

Active Member
#13
Even with the changes NiteWave gave me for .htaccess, members are reporting trouble staying logged in. I noticed the same thing - seemingly random pages showing as logged out and then others showing logged in (without re-logging in). Maybe it has to do with other rewrite rules I have in .htaccess. I will try to figure it out because I really want this to work!

This is what my .htaccess looks like. Would any of the rest of this content in my .htaccess interfere with LSCache?

Code:
RewriteEngine On

## Forward non-www to www
RewriteCond %{HTTP_HOST} ^photographerslounge.org
RewriteRule (.*) http://www.photographerslounge.org/$1 [R=301,L]

## Forward index.php to root directory
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L]

## Forward vBSEO to non-vBSEO URLs after uninstalling vBSEO
RewriteRule [^/]+/[^/]+-([0-9]+)/ http://www.photographerslounge.org/showthread.php?t=$1 [L,R=301]
RewriteRule ^f([0-9]+)/$ http://www.photographerslounge.org/forumdisplay.php?f=$1 [L,R=301]
RewriteRule ^members/(.+)/ http://www.photographerslounge.org/member.php?username=$1 [L,R=301]

## select which pages to cache
RewriteCond %{HTTP_COOKIE} !bbimloggedin=yes
RewriteCond %{HTTP_COOKIE} !bbuserid=
RewriteCond %{HTTP_COOKIE} !bbpassword=
RewriteCond %{REQUEST_METHOD} ^HEAD|GET$
RewriteCond %{QUERY_STRING} !s=[a-fA-F0-9]{32}
RewriteCond %{QUERY_STRING} !product=vbnexus
RewriteCond %{REQUEST_URI} !^/(login|register|usercp|private|profile|cron|image)\.php$
RewriteCond %{REQUEST_URI} !^/admincp
RewriteRule ^(.*\.php)?$ - [E=Cache-Control:max-age=120]
 
Last edited:

asabet

Active Member
#14
Could it be that litespeed_cache.xml isn't compatible with the latest vBulletin 4.2.2?

Update:

I am trying this again after uninstalling the Unixy plugin. My .htaccess looks like this:

Code:
RewriteEngine On

## Forward non-www to www
RewriteCond %{HTTP_HOST} ^photographerslounge.org
RewriteRule (.*) http://www.photographerslounge.org/$1 [R=301,L]

## select which pages to cache
RewriteCond %{HTTP_COOKIE} !bbimloggedin=yes
RewriteCond %{HTTP_COOKIE} !bbuserid=
RewriteCond %{HTTP_COOKIE} !bbpassword=
RewriteCond %{REQUEST_METHOD} ^HEAD|GET$
RewriteCond %{QUERY_STRING} !s=[a-fA-F0-9]{32}
RewriteCond %{QUERY_STRING} !product=vbnexus
RewriteCond %{REQUEST_URI} !^/(login|register|usercp|private|profile|cron|image)\.php$
RewriteCond %{REQUEST_URI} !^/admincp
RewriteRule ^(.*\.php)?$ - [E=Cache-Control:max-age=120]

## Forward index.php to root directory
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L]

## Forward vBSEO to non-vBSEO URLs after uninstalling vBSEO
RewriteRule [^/]+/[^/]+-([0-9]+)/ http://www.photographerslounge.org/showthread.php?t=$1 [L,R=301]
RewriteRule ^f([0-9]+)/$ http://www.photographerslounge.org/forumdisplay.php?f=$1 [L,R=301]
RewriteRule ^members/(.+)/ http://www.photographerslounge.org/member.php?username=$1 [L,R=301]
Does that all look okay?
 
Last edited:

asabet

Active Member
#15
I think I figured out the problem - I had to remove the index.php to root redirect and change my cookie domain from .photographerslounge.org to blank. Now it seems to be working.
 

asabet

Active Member
#17
Like this?

Code:
Options +FollowSymLinks
RewriteEngine On

## Forward non-www to www and rewrite vBSEO URLs after uninstalling vBSEO
RewriteCond %{HTTP_HOST} ^photographerslounge.org
RewriteRule (.*) http://www.photographerslounge.org/$1 [R=301,L]
RewriteRule [^/]+/[^/]+-([0-9]+)/ http://www.photographerslounge.org/showthread.php?t=$1 [L,R=301]
RewriteRule ^f([0-9]+)/$ http://www.photographerslounge.org/forumdisplay.php?f=$1 [L,R=301]
RewriteRule ^members/(.+)/ http://www.photographerslounge.org/member.php?username=$1 [L,R=301]

## Forward index.php to root directory
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L]

## select which pages to cache
RewriteCond %{HTTP_COOKIE} !bbimloggedin=yes
RewriteCond %{HTTP_COOKIE} !bbuserid=
RewriteCond %{HTTP_COOKIE} !bbpassword=
RewriteCond %{REQUEST_METHOD} ^HEAD|GET$
RewriteCond %{QUERY_STRING} !s=[a-fA-F0-9]{32}
RewriteCond %{QUERY_STRING} !product=vbnexus
RewriteCond %{REQUEST_URI} !^/(login|register|usercp|private|profile|cron|image)\.php$
RewriteCond %{REQUEST_URI} !^/admincp
RewriteRule ^(.*\.php)?$ - [E=Cache-Control:max-age=120]
 

asabet

Active Member
#18
I tried that and still get random logouts when clicking on threads.

Edit: I uninstalled Unixy Varnish plugin as suggested, and there is no noticeable difference in performance, so I am done with Unixy Varnish completely. As such, the title of this thread doesn't apply anymore. Please close this thread as solved. I will start another thread for help in getting LScache working for my forums.
 
Last edited:
#19
for your site, cookie's prifix is "bb_" instead of "bb", so change above rules:
bbimloggedin -> bb_imloggedin
bbuserid -> bb_userid
bbpassword -> bb_password
etc
 
Top