Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
litespeed_wiki:litespeed:cache:ipboard [2015/07/27 13:32]
Michael Alegre removed
— (current)
Line 1: Line 1:
-====== LSWS Cache + IP Board ====== 
-===== Summary ===== 
-In order for LSWS Cache and IP Board to work together, IP Board needs to be modified to send out  
-a ‘Cache-Control:​ Private’ response header to logged-in users. LSWS will take care of the rest.  
  
-===== Procedures ===== 
-Here are the steps that will enable LSWS to work with IP Board: 
- 
- 
- 
- 
- 
-==== Modify IP Board code ==== 
-  
-File admin/​sources/​classes/​output/​formats/​html/​htmlOutput.php needs to be modified to  
-send out a ‘**cache-control:​ private**’ response header to logged-in users. Essentially,​ the  
-response header is a flag that notifies LSWS what kind of cache to serve, which is the only  
-information LSWS needs to know in order to work with IP Board. ​ 
- 
-Below changes are for IPB v3.1.4 as an example: 
-<​code>​ 
-# diff -Naur a/​htmlOutput.php b/​htmlOutput.php 
-—-- a/​htmlOutput.php ​   2011-03-16 15:​39:​09.000000000 -0400 
-+++ b/​htmlOutput.php ​   2011-06-27 00:​39:​38.000000000 -0400 
-@@ -73,6 +73,17 @@ 
-        public function printHeader() 
-        { 
-                //​—————————————– 
-+               // Add "​cache-control:​ private"​ header 
-+               // ​     for logged in users 
-+               // this is for LiteSpeed cache requirement 
-+               //​—————————————– 
-+               if ( $this->​memberData['​member_id'​] ) 
-+               { 
-+                       ​header( "​cache-control:​ private"​ ); 
-+               } 
-+ 
-+ 
-+               //​—————————————– 
-                // Start GZIP compression 
-         //​—————————————– 
-        
-@@ -1062,4 +1073,4 @@ 
-  
-                return $texts[ array_rand($texts) ]; 
-        } 
-# 
- 
-</​code>​ 
- 
-**Note:** To verify, check the response header when you log in.  Server response header 
-"​Cache-Control:​ private"​ should be seen: 
-<​code>​ 
-HTTP/1.1 200 OK 
-Content-Encoding:​ gzip 
-Vary: Accept-Encoding 
-Transfer-Encoding:​ chunked 
-Date: Wed, 20 Jul 2011 16:59:30 GMT 
-Server: LiteSpeed 
-Connection: close 
-... 
-Cache-Control:​ private ​ <==== this is the header 
-... 
-</​code>​ 
- 
- 
- 
- 
- 
-==== Set up Cache Policy ==== 
- 
-In LiteSpeed (v4.1.2 or later) Admin CP -> Configuration -> Server -> Cache 
-<​code>​ 
-Storage Path: /​dev/​shm/​diskcache 
-Max Object Size: 1024000 
- 
-Cache Policy 
-Enable Cache: ​   No 
-Cache Expire Time (seconds): ​   Not Set 
-Cache Request with Query String: ​   No 
-Cache Request with Cookie: ​   Yes 
-Cache Response with Cookie: ​   Yes 
-Ignore Request Cache-Control: ​   Yes 
-Ignore Response Cache-Control: ​   No 
-Enable Private Cache: ​   Yes 
-Private Cache Expire Time (seconds): ​   60 
-</​code>​ 
-Do-Not-Cache URL(s): 
-<​code>​ 
-/​index.php?​app=forums&​module=post&​section=post&​do=edit_post 
-/​index.php?​app=forums&​module=post&​section=post&​do=reply_post 
-/​index.php?​app=forums&​module=moderate&​section=moderate&​do=postchoice 
-</​code>​ 
-**Note:** Do-Not-Cache URL box holds all of the URL(s) that should **NOT** be cached. 
- 
- 
- 
- 
-==== Create Rewrite Rules for guest/​public caching ==== 
- 
-Input the following rules into .htaccess in front of existing Rewrite rules. 
- 
-<​code>​ 
-RewriteEngine On 
-###########################################​ 
-# For LiteSpeed public cache (guest user) 
-###########################################​ 
-RewriteCond %{REQUEST_METHOD} ^HEAD|GET$ 
-RewriteCond %{HTTP_COOKIE} !member_id= [OR] 
-RewriteCond %{HTTP_COOKIE} member_id=0 
-RewriteCond %{REQUEST_URI} !^/admin 
-RewriteCond %{REQUEST_URI} !(css|js|png|gif)$ 
-RewriteCond %{QUERY_STRING} ​ ^$ 
-RewriteRule .* – [E=Cache-Control:​max-age=360] 
-</​code>​ 
- 
-**Note:​** ​ 
-   - Above rules are for guest user (the cookie does not contain ‘member_id’ at all or contains ‘member_id=0’). ​ 
-   - Do NOT cache for admin user. 
-   - Do NOT cache static objects. 
-   - Do NOT cache URL with Query String to stay on the safe side. 
-   - Cache for 6 minutes. 
-   - For public cache, "​X-LiteSpeed-Cache:​ hit" response header should be seen. 
-   - For private cache, "​X-LiteSpeed-Cache:​ private,​hit"​ response header should be seen. 
- 
-==== Create cronjob code to clean up stale cache ==== 
- 
-<​code>​ 
-0 */2 * * * find /​dev/​shm/​diskcache -type f -mmin 120 –delete 
-</​code>​ 
- 
- 
-==== Add entries to /​etc/​rc.local ==== 
-  
- 
-     echo "mkdir /​dev/​shm/​diskcache && chmod nobody.lsadm"​ >> /​etc/​rc.local 
-     echo "/​dev/​shm/​diskcache && chmod 770 /​dev/​shm/​diskcache"​ >> /​etc/​rc.local 
-    ​ 
-**Note:** this is to make sure cache directory gets created when server is booted up. 
  • Admin
  • Last modified: 2015/07/27 13:32
  • by Michael Alegre