[solved] vBulletin + LiteSpeed Cache

Discussion in 'LiteSpeed Cache' started by andych, May 12, 2013.

  1. andych

    andych New Member

    I did exactly what your instruction except for the vbseo (because I don't use vbseo)

    But still getting the same issue.

    [​IMG]
  2. NiteWave

    NiteWave Administrator

    please PM the vBulletin's admin access, I'll do the final check.
  3. andych

    andych New Member

    Hi, PM Sent!
  4. NiteWave

    NiteWave Administrator

    vBulletin settings looks ok.
    it looks that cache rewriterule not enabled.
    please enable it, I'm testing it.
  5. andych

    andych New Member

    it is now enabled and still having the same issue :confused:

    need assistance asap as it is on a production environment :(

    Code:
    [i]root@eden:~# [b]cat /var/www/.htaccess[/b][/i]
    #php_flag suhosin.cookie.encrypt Off
    #php_value suhosin.request.max_vars 2048
    #php_value suhosin.post.max_vars 2048
    
    order allow,deny
    allow from all
    
    deny from 1.2.3.4 #bad-ips
    
    Options +FollowSymlinks
    RewriteEngine On
    RewriteBase /
    RewriteCond %{http_host} ^my.dom
    RewriteRule ^(.*) http://www.my.dom/$1 [R=301,L]
    
    RewriteCond %{HTTP_COOKIE} !bbimloggedin=yes
    RewriteCond %{HTTP_COOKIE} !bbuserid=
    RewriteCond %{HTTP_COOKIE} !bbpassword=
    
    RewriteCond %{HTTP_COOKIE} !if_imloggedin=yes
    RewriteCond %{HTTP_COOKIE} !if_userid=
    RewriteCond %{HTTP_COOKIE} !if_password=
    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 (.*) - [E=Cache-Control:max-age=120]
    
    # RewriteRule /test.php - [L,E=Cache-Control:max-age=120]
    
    RewriteRule ^home/$ forum.php [L,R=301]
    RewriteRule ^f([0-9]+)/$ forumdisplay.php?f=$1 [L,R=301]
    RewriteRule ^f([0-9]+)-([0-9]+)/$ forumdisplay.php?f=$1&page=$2 [L,R=301]
    RewriteRule ^t([0-9]+)/$ showthread.php?t=$1 [L,R=301]
    RewriteRule ^t([0-9]+)-([0-9]+)/$ showthread.php?t=$1&page=$2 [L,R=301]
    RewriteRule ^t([0-9]+)-print/$ showthread.php?t=$1 [L,R=301]
    RewriteRule ^blogs/u([0-9]+)-e([0-9]+)/$ entry.php?b=$2 [L,R=301]
    [i]root@eden:~# [/i]
    Last edited: May 14, 2013
  6. NiteWave

    NiteWave Administrator

    there is an extra space in line:
    before \.php$.
    please remove it

    and please remove the 3 lines:
    sine your cookie is start from if_
  7. andych

    andych New Member

    Code:
    [I]root@eden:~#[/I] [I][B]cat /var/www/.htaccess[/B][/I]
    #php_flag suhosin.cookie.encrypt Off
    #php_value suhosin.request.max_vars 2048
    #php_value suhosin.post.max_vars 2048
    
    order allow,deny
    allow from all
    
    deny from 1.2.3.4 #bad-ips
    
    Options +FollowSymlinks
    RewriteEngine On
    RewriteBase /
    RewriteCond %{http_host} ^my.dom
    RewriteRule ^(.*) http://www.my.dom/$1 [R=301,L]
    
    #removed 3 lines below by request of NiteWave@LS 20130514 1157.G+7
    #RewriteCond %{HTTP_COOKIE} !bbimloggedin=yes
    #RewriteCond %{HTTP_COOKIE} !bbuserid=
    #RewriteCond %{HTTP_COOKIE} !bbpassword=
    
    RewriteCond %{HTTP_COOKIE} !if_imloggedin=yes
    RewriteCond %{HTTP_COOKIE} !if_userid=
    RewriteCond %{HTTP_COOKIE} !if_password=
    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 (.*) - [E=Cache-Control:max-age=120]
    
    # RewriteRule /test.php - [L,E=Cache-Control:max-age=120]
    
    RewriteRule ^home/$ forum.php [L,R=301]
    RewriteRule ^f([0-9]+)/$ forumdisplay.php?f=$1 [L,R=301]
    RewriteRule ^f([0-9]+)-([0-9]+)/$ forumdisplay.php?f=$1&page=$2 [L,R=301]
    RewriteRule ^t([0-9]+)/$ showthread.php?t=$1 [L,R=301]
    RewriteRule ^t([0-9]+)-([0-9]+)/$ showthread.php?t=$1&page=$2 [L,R=301]
    RewriteRule ^t([0-9]+)-print/$ showthread.php?t=$1 [L,R=301]
    RewriteRule ^blogs/u([0-9]+)-e([0-9]+)/$ entry.php?b=$2 [L,R=301]
    [I]root@eden:~#[/I] 
    Are you the one that added 3 lines below ?
    Code:
    RewriteCond %{HTTP_COOKIE} !if_imloggedin=yes
    RewriteCond %{HTTP_COOKIE} !if_userid=
    RewriteCond %{HTTP_COOKIE} !if_password=
  8. NiteWave

    NiteWave Administrator

    yes. looks working now.
    another change I did is
    Virtual Hosts-> ...org->Cache->Enable Cache:"Not Set"->"No"
    and restarted lsws
  9. andych

    andych New Member

    Thanks NiteWave, now looks better, but I couldn't find the 'cached' thing in the header:

    [​IMG]
    Last edited: May 14, 2013
  10. NiteWave

    NiteWave Administrator

    from the screenshot, it's correct result.
    please look at the cookie from the screenshot:
    if_usrid=1
    if_password=...
    when these strings exist in cookie, indicate that this is a logged in user, so NOT return the cache. cache is for guest only.
    so you just logout and visit your forum again as a guest, you'll see the cache hit header.

    another suggestion : now guest cache time set to 120 seconds(i.e., 2 minutes), you can increase it to 5 minutes, 10/15/30 etc, since the cache is for guest users only.
    this will improve the performance for both guest and logged in users. people will feel your forum faster, response quickly.
    Last edited: May 14, 2013
  11. andych

    andych New Member

    I see, just want to confirm that: after user logged in, the cache is not caching and only caching for guests (not logged in users) ?

    Ps: Where I can set the guest cache time?
  12. NiteWave

    NiteWave Administrator

    yes. otherwise will have the issue you reported in the #19 post of this thread.
  13. andych

    andych New Member

    Thank you very much for your assistance, NiteWave.. Now I see everything's clear :D

    I've set to 'RewriteRule (.*) - [E=Cache-Control:max-age=300]' (5 Minutes)

    And I see:
    Code:
    RewriteCond %{REQUEST_URI} !^/admincp
    on .htaccess, do I have to add the /modcp as well?
    Last edited: May 14, 2013
  14. NiteWave

    NiteWave Administrator

    yes, should add /modcp as well and other URLs should not be cached.
  15. andych

    andych New Member

    Thanks for confirming, I've added:
    Code:
    RewriteCond %{REQUEST_URI} !^/modcp
    Now it's working as expected, once again thank you for your kind assistance NiteWave!

    Have a great day always!
  16. andych

    andych New Member

    Hi again NiteWave,

    Is it normal with the 1h:17m:27s uptime and we got 7.33% cache hit rate?

    [​IMG]
  17. NiteWave

    NiteWave Administrator

    current algorithm,
    Cache Hit Rate = Total Cache Hits / Total Req = 1,288/17,574 = 7.33%

    but since lsws don't cache static content, like .css/.js/.jpg etc, but these static content also counts as Req, so the cache hit rate looks low.
  18. andych

    andych New Member

    How to make LSWS cache all static files for both logged in users and guests?

    Any downside for it?
  19. NiteWave

    NiteWave Administrator

    lsws don't cache static content since it's not needed at all or in most scenarios.
    lsws serve static content quickly and consume little system resource.
    when a static content i.e., an image is requested repeatedly, linux may cache the image in memory, so lsws serve the image more quickly. it's automatic, and won't consume lsws process's own memory. so if lsws serve static contents only, you will notice lsws process keep on low memory and low load all the time and yet very fast. or in other words, the static contents are cached by linux kernel automatically. lsws just make good use of the linux kernel file system's great efficiency. if you wish some static content always in cache(or memory), you can put these files under /dev/shm, no need ask lsws to put it in memory as well.
  20. andych

    andych New Member

    Oh, got it.. Thank you for your detailed explanation :)

Share This Page