Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
litespeed_wiki:litespeed:cache:vbulletin [2015/07/27 13:36] Michael Alegre removed |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== LSWS Cache + vBSEO (Guest Cache) ====== | ||
- | ===== Summary ===== | ||
- | LSWS Cache can be setup for vBSEO with vB cache plugin for guest cache. | ||
- | |||
- | |||
- | |||
- | |||
- | ===== Perquisites ===== | ||
- | |||
- | vBulletin 3/4 | ||
- | vBSEO 3.6.0 | ||
- | LiteSpeed WebServer 4.0+ (supports public cache) | ||
- | |||
- | |||
- | |||
- | |||
- | ===== Procedures ===== | ||
- | 1. Save the following Cache plugin for vBulletin 3/4 to a file say litespeed_cache.xml | ||
- | <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> | ||
- | </code> | ||
- | |||
- | |||
- | 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 | ||
- | <code> | ||
- | RewriteEngine On | ||
- | </code> | ||
- | add | ||
- | <code> | ||
- | #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 %{REQUEST_METHOD} ^HEAD|GET$ | ||
- | RewriteCond %{QUERY_STRING} ^$ | ||
- | RewriteRule (.*) - [E=Cache-Control:max-age=60] | ||
- | #rules for litespeed cache: end | ||
- | </code> | ||
- | 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 | ||
- | <code> | ||
- | 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): | ||
- | </code> | ||
- | **Note:** | ||
- | |||
- | - Cache storage can be set to /dev/shm/diskcache to avoid disk I/O wait if enough memory can be spared. | ||
- | - Cache resource with size less than 128KB. | ||
- | - your vB's coookie name may vary, for example my_userid instead of bbuserid, depends on your vB configuration. | ||
- | - 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. | ||
- | |||
- | |||
- | |||
- | ===== Crate a cronjob to clean up stale cache ===== | ||
- | |||
- | <code> | ||
- | */10 * * * * find /diskcache -type f -mmin +10 –delete | ||
- | </code> | ||
- | |||
- | **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. |