LiteSpeed Cache - Community

LiteSpeed Cache - Community 1.0.4.3

No permission to download
I did add this as per instruction:

### LSCACHE START LOGIN COOKIE ###
RewriteRule .* - [E="cache-vary:xf_style_id"]
### LSCACHE END LOGIN COOKIE ###

But it didn't work.

Note that I'm using TMA mobile app to force load certain style for the app users. But then, the same cache is served across app & non-app users.

You may need to dump the request's information to see what the requests with the mobile app look like. It is possible that they aren't using that cookie.

Could you PM me ssh information so I can set this up? As well as a link to your site.

Thanks @lsKevin , I used the WHM script and now getting X-LiteSpeed-Cache: hit (y)

Glad to hear it! Let us know if you run into any more issues!

Is it possible to count visits to the Threads of the guests?

This may be possible, but would probably defeat the purpose of the cache, as it will likely require loading PHP. Will look into this shortly and let you know what I find.
 
Hello, i want to ask about mobile cache separation.

I use this add on
https://xenforo.com/community/resources/browser-detection-mobile-msie.1098/

And i use template such as this :
PHP:
<xen:if is="!{$visitor.getBrowser.isMobile}">
    i am desktop
<xen:else />
    i am mobile
</xen:if>

I also have checked the mobile option in Litespeed Cache add on.

I also have added these lines in my htaccess :
Code:
# LS Cache
<IfModule LiteSpeed>
  #CacheLookup public on
</IfModule>

RewriteCond %{HTTP_USER_AGENT} NokiaN[^\/]*|\ Mobile(\ Safari)?\/|SymbianOS|Silk-Accelerated|Opera(\ |\/)(Mini|8|9\.[0-7])|IEMobile\/|^BlackBerry [NC]
RewriteRule .* - [E=Cache-Control:vary=ismobile]

RewriteCond %{HTTP_COOKIE} !xf_session [NC]
RewriteRule (.*)?$ - [E=Cache-Control:no-cache]

But it seems cache of mobile & desktop view are randomly served.
For example mobile user gets cached desktop view, and vice versa.

What setting should i check ?

Thank you
 
Hi @semprot,

Apologies for the late reply, did not get an email notification for your message.

Are you comfortable with modifying the code?

If so, we're looking at library/Litespeedcache/Listener/Global.php ~ line 240

Replace
Code:
        $is_mobile = XenForo_Visitor::isBrowsingWith('mobile');

with

Code:
$visitor = XenForo_Visitor::getInstance();

  //Check if mobile
  if( class_exists('Sedo_DetectBrowser_Listener_Visitor') && isset($visitor->getBrowser['isMobile']))
  {
  //External Addon
  $is_mobile = $visitor->getBrowser['isMobile'];
  }
  else
  {
  //XenForo
  $is_mobile =  XenForo_Visitor::isBrowsingWith('mobile');
  }

That should replace the XenForo check with that plugin's check when the plugin is installed.

Let me know how it goes,
Kevin
 
Hi @semprot,

Apologies for the late reply, did not get an email notification for your message.

Are you comfortable with modifying the code?
Thank you, it works now :)

However when i do further testing, which is refreshing home page several times (+- 5 seconds interval) & checking the HTTP header code,
X-LiteSpeed-Cache returns "miss" and "hit" "randomly" (i think it is a kind of random).

Here is my cache plugin setting :
Home Page TTL (seconds) : 300 (default)
Public TTL (seconds) : 28800 (default)

On my litespeed server >> cache setting, all are set to "Not Set",
except "Cache Response with Cookie" which is "Yes".
 
Hi @semprot

I think that is normal. The idea is that the relevant pages will purge whenever someone posts a reply or new thread.

For example, you have a forum list, forum, and threads. When someone replies to a thread, that thread, the forum, and the forum list all need to be updated to reflect the new post.

That just means you have a very active forum :)

Cheers,
Kevin
 
When someone replies to a thread, that thread, the forum, and the forum list all need to be updated to reflect the new post.
My suggestion is : because this add on caches guests only, the cached data does not need to be refreshed if something is updated in the thread / post / forum.
Unless the visitor logs in :)

This is a great add on. Thank you.
 
Having trouble getting this to work when I check headers I don't see X-LiteSpeed-Cache: hit. When I verify litespeed cache management -> actions everything seems to be OK.

Hope you can help, thanks!
 
Having trouble getting this to work when I check headers I don't see X-LiteSpeed-Cache: hit. When I verify litespeed cache management -> actions everything seems to be OK.

Hope you can help, thanks!
Have you added this to your .htaccess?

Code:
# LS Cache
<IfModule LiteSpeed>
  #CacheLookup public on
</IfModule>
 
@semprot We will take that suggestion and consider adding an option for it. However, one of our primary focuses is to provide an accurate cache, and doing so would kind of defeat that purpose :D

@bloop What semprot mentioned is kind of correct - I'm not sure why his has a comment in front of CacheLookup, but that should be inserted into the .htaccess as well. If you run your own hosting, please check out the options here. If you have a server admin, please send him/her the link so the cache can be set up. We can also take a look at it if you don't mind pm'ing me the ssh information.

Cheers,
Kevin
 
Good morning @lsKevin @semprot

I've added this to .htaccess
Code:
<IfModule LiteSpeed>
CacheLookup public on
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} NokiaN[^\/]*|\ Mobile(\ Safari)?\/|SymbianOS|Silk-Accelerated|Opera(\ |\/)(Mini|8|9\.[0-7])|IEMobile\/|^BlackBerry [NC]
RewriteRule .* - [E=Cache-Control:vary=ismobile]
RewriteCond %{HTTP_COOKIE} !xf_session [NC]
RewriteRule (.*)?$ - [E=Cache-Control:no-cache]
</IfModule>

Webadmin>Server>Cache settings
image-1.webp

I followed the instructions in this link with no luck and prior to that via WHM>litespeed, I used "Cache Root Setup" to set up the cache folders.. I don't have wordpress but I assumed that would work..hope I didn't mess something up by doing that.
Untitled-4.webp
 
Hi @bloop

Your settings seem to be correct. Perhaps the issue is simpler than we thought: are you visiting your site with a non-logged in browser? Logged in users will not see cache hit or miss.

Cheers,
Kevin
 
@lsKevin deleted, restarted litespeed, the folder generated again but no luck.. don't see litespeed in header and no cached files in folder either. Not sure if this matters but this is my full .htaccess file could the order cause a problem?

Code:
#    Mod_security can interfere with uploading of content such as attachments. If you
#    cannot attach files, remove the "#" from the lines below.
#<IfModule mod_security.c>
#    SecFilterEngine Off
#    SecFilterScanPOST Off
#</IfModule>

ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 405 default
ErrorDocument 406 default
ErrorDocument 500 default
ErrorDocument 501 default
ErrorDocument 503 default
<IfModule mod_rewrite.c>
    RewriteEngine On
RewriteCond %{HTTP_HOST} ^domainname.com [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ http://www.domainname.com/$1 [L,R=301,NC]
    #    If you are having problems with the rewrite rules, remove the "#" from the
    #    line that begins "RewriteBase" below. You will also have to change the path
    #    of the rewrite to reflect the path to your XenForo installation.
    #RewriteBase /xenforo

    #    This line may be needed to enable WebDAV editing with PHP as a CGI.
    #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule ^.*$ - [NC,L]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule ^.*$ index.php [NC,L]
</IfModule>
<IfModule LiteSpeed>
CacheLookup public on
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} NokiaN[^\/]*|\ Mobile(\ Safari)?\/|SymbianOS|Silk-Accelerated|Opera(\ |\/)(Mini|8|9\.[0-7])|IEMobile\/|^BlackBerry [NC]
RewriteRule .* - [E=Cache-Control:vary=ismobile]
RewriteCond %{HTTP_COOKIE} !xf_session [NC]
RewriteRule (.*)?$ - [E=Cache-Control:no-cache]
</IfModule>
 
Aha, yes, that could be it!

The rules should be added probably before the group of errordocuments rules rather than at the bottom.
 
Top Bottom