Failure to Set Up vBulletin Cache

ShannonA

Well-Known Member
#1
I've been trying to set up the vBulletin cache in accordance with the instructions here:
http://blog.litespeedtech.com/2011/01/28/speed-up-vbulletin-sites-through-litespeed-built-in-cache/

FIRST problem, the Rewrite rules don't seem to work right.

I put them in as follows for our site at "forum.rpg.net":
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]
When I do so, I don't get any results from my log files, even when I turn debugging up to '9' and INFO logging on. Then, I delete this line:
RewriteCond %{REQUEST_URI} !^/(login|register|usercp|private|profile|cron|image) \.php$
And things start logging correctly ... which implies to me that there's something very wrong with that line, but I can't figure out what.

Even when I have that line temporarily removed (for testing only, as clearly the site wouldn't work well with it missing!), caching doesn't seem to work. I look at my caching directory and there's nothing there, and I don't see the X-Litespeed-Cache headers.
atropos:/var/log/lsws/rpgnet# !ls
ls -lag /var/www/litespeedcache/
total 8
drwx------ 2 www-data 4096 Oct 25 2012 .
drwxrwxr-x 28 www-data 4096 Sep 10 11:38 ..
(The user with permissions matches the web server.)

Despite that, I do see this sort of thing logging (while I have that bad line out):
[REWRITE] apply cache-control: 'max-age=120'.
[REWRITE] Source URI: '/showthread.php' => Result URI: '..?'
[REWRITE] Last Rule, stop!
So any ideas on how to fix these two problems?

This is vB 4.2.2; has the cache stopped working after 4.0?

Main Cache Setting:
Cache Storage Settings Edit
Storage Path




/var/www/litespeedcache
Max Object Size




Not Set
Cache Policy Edit
Enable Cache






Not Set
Cache Expire Time (seconds)




Not Set
Cache Stale Age (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
Do-Not-Cache URL


Edit
Not Set
Do-Not-Cache Domains




Edit
Not Set
Virtual Host Cache Setting:
Cache Policy Edit
Enable Cache






No
Cache Expire Time (seconds)




Not Set
Cache Stale Age (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







Not Set
Private Cache Expire Time (seconds)




Not Set
 
Last edited:

ShannonA

Well-Known Member
#2
FIRST problem, the Rewrite rules don't seem to work right.
I figured this one out. There's a typo on the explanation page. This:
RewriteCond %{REQUEST_URI} !^/forum/(login|register|usercp|private|profile|cron|image) \.php$
Should be this:
RewriteCond %{REQUEST_URI} !^/forum/(login|register|usercp|private|profile|cron|image)\.php$
(e.g., there was an extraneous space)

If that could be fixed for future cachers, that'd be great.

As for the lack of caching, I just realized that every attempt to cache ends with an error. Ah hah! I can't tell what it means though because it doesn't show the full info ...
[REWRITE] apply cache-control: 'max-age=120'.
[REWRITE] Source URI: '/showthread.php' => Result URI: '..?'
[REWRITE] Last Rule, stop!
File not found [/var/www/rpgnet/forums/vb422/...]
Any ideas what this might be hinting at?
 

ShannonA

Well-Known Member
#3
I turned on caching for the whole server (unclear to me if that was meant to be one of the requirements or not, as it's not explicited listed in the instruction pages) and caching did occur for other subsites, but not for the forums set up as above. So, the base caching setup looks OK, but the caching still isn't occurring due to those rewrites ...
 

ShannonA

Well-Known Member
#4
And the SECOND problem looks to be another problem with the Rewrite rules as listed.

Something about this is funky, and was causing the unknown files:
RewriteRule /(.*\.php)?$ – [L,E=Cache-Control:max-age=120]
I rewrote it by hand to get rid of any hidden spaces or weird characters, and also brought it up to date with modern vBulletin (which tends to have SEO stuff at the end of a URL, rather than ending with .php). I came up with the following:

RewriteRule ^/(.*\.php)? - [L,E=Cache-Control:max-age=120]
It's now caching, but at a much lower rate than I'd expect. Does this look good, or am I still missing something?
 

ShannonA

Well-Known Member
#5
And the problems continue.

When I got things running, suddenly some people who were logged in were getting their pages cached, despite the inclusion of the aforementioned rules.

I discovered that the listing isn't in sync with the xml file for vBulletin. The xml files creates 'imloggedin' while the RewriteRules look for 'bbimloggedin'.

However even after that fix *some* people seemed to be getting pages cached when they were logged in.

So I dug up the "header('X-LiteSpeed-Cache-Control: no-cache')" response header, and I tried to put it in ... but it never shows up. I know it's not my coding because creating the imaginary ""header('X-LiteSpeed-Cache: no-cache')" works fine, but as soon as I add on the "-Control" none of my response header reporting apps see it any more.

Sadly, I'm about to give up with all the errors in the documentation and the frustration with it then caching incorrectly, on top of everything!
 

NiteWave

Administrator
#6
I'll update the blog after confirming with your case.
Sorry for having troubled you so much.

the rewriterule
RewriteRule /forum/(.*\.php)?$ – [L,E=Cache-Control:max-age=120]
please remove the "L" flag, i.e.,
RewriteRule /forum/(.*\.php)?$ – [E=Cache-Control:max-age=120]
and, if these rules are put in .htaccess, need change to
RewriteRule (.*\.php)?$ – [E=Cache-Control:max-age=120]
this is because of apache's per-server and per-directory rewriterule difference.

for cookie name bbimloggedin/bbuserid/bbpassword, the "bb" is prefix, added by vBulletin and configurable, your setting may vary. in firebug, can check what it is for your vB.

for testing purpose, you can just enable cache for 1 URL only first, for example, the homepage of the forum. just change the rewriterule to
RewriteRule ^$ – [L,E=Cache-Control:max-age=120]
(assume you put these rules in .htaccess)
 

ShannonA

Well-Known Member
#7
Testing just on the front page sounds like a great idea; thanks.

(I've been using the Rewrite area of the Virtual Host panel in the LSWS admin pages, so what would be the best Rewrite rule for just the front page of http://forum.rpg.net, which doesn't have a /forum/ directory.)

PS: Would love any ideas on why I can't create a header('X-LiteSpeed-Cache-Control: no-cache') header; I even put that in just plain PHP, and it doesn't work!
 

NiteWave

Administrator
#8
I've been using the Rewrite area of the Virtual Host panel in the LSWS admin pages, so what would be the best Rewrite rule for just the front page of http://....net, which doesn't have a /forum/ directory.
should be
RewriteRule ^/$ – [E=Cache-Control:max-age=120]
PS: Would love any ideas on why I can't create a header('X-LiteSpeed-Cache-Control: no-cache') header; I even put that in just plain PHP, and it doesn't work!
it works but for internal communication only, between litespeed process and lsphp process, not intend to show up in final response headers.
 
Top