Does LSCache for Drupal handle *all* Drupal caches?

iky

New Member
#1
Hello. I'm looking into migrating to Litespeed+LSCache on Drupal. Our current setup is apache+php-fpm, memcached, APCu. Memcached is set as our default cache backend and we have it assigned specifically to handle render and dynamic page cache bins. APCu is set to handle the boostrap, config, discovery cache bins.

What I'm trying to figure out is what is and is not handled by LSCache and which, if any, cache bins are better or need to be handled by memcached and APCu. Does anyone have a sense of this?

My impression is that LSCache handles all Drupal cache, but then again it seems odd maybe for a webserver to keep track of session cache (maybe just due to my unfamiliarity with caching), so I don't know. Further, I know that memcached and LSCache may work in parallel, but, again, it's unclear whether memcached in the situation I've described above needs to be active when LScache is active (both as a module and on the webserver).

Thanks for your any insight y'all may have on this!
 

serpent_driver

Well-Known Member
#2
First of all and this you surely know is, that LScache is a HTTP cache. That means, that every php based file/URL is cached if it is part of the request. The result of this cache is the generated output of a request. This is the basic function of a HTTP cache. If LScache is enabled by a single line of code in .htaccess (without plugin) the complete output is cached. If a URL is already cached only a static copy of this URL is sent. A static copy (simple, but compressed HTML file) can't generate sessions or can generate dynamically database queries. It is pure HTML. LScache without any exceptions for caching is like a hyper sport car without brakes and steering wheel, only full throttle and high speed. If a page is already cached normally you don't need any other cache methods like Memcached, APCu or other, especially as such function can't be executed if cached page contains only HTML. If you need a session or other dynamically generated content or if you want to exclude pages from being cached, you must exclude them from caching either by plugin settings, simple rewrite rules in .htaccess or with ESI (Edge Side Includes).

I hope this helps?

FYI: LiteSpeed Memcached is supported by LiteSpeed webserver, but not LScache.
 
Last edited:

iky

New Member
#3
Hi. Thanks for the reply.

Drupal has, for instance, a dynamic page cache. By default Drupal uses mysql/mariadb for its cache. But this can be set to memcached, as in our configuration.

What I'm not clear on is this: If we run litespeed+lscache and the Drupal lscache module, does the need for, say, the dynamic page cache in memcached disappear? If dynamic page cache is stored in memcached, then if dynamic page P is cached it will get served through memcached assuming it's not stale, has expired etc. But LSCache would also presumably store the content of P and server it when requests for P come in.

If this is right (and maybe it's not), then we'd have a situation where dynamic page cache for page P is effectively duplicated in memcached and LSCache, but only served from LSCache. Since memcahced is the default cache backend for Drupal in this example, P gets written to dynamic page cache in memcached, and then litespeed+LSCache cache P. But when a user requests P, assuming it hasn't expired, will be served from lscache and not memcached. So it *seems* (but might not be the case) that memcached isn't need in this case. Is this correct?

Regarding the LSCache Drupal module, what is it telling the litespeed server+LSCache to expire and how? Are only individual pages expired? If we update a dynamic page P in Drupal that is cached by LSCache, will the LSCache Drupal module expire only that page or will it expire a larger set of pages than the set containing just P? Or it will expire all dynamic cache? The module admin interface only allows expiring all lscache (for the site or globally). This might suggest that the LSCache Drupal module expires all cache for the site on update, but this woudln't be very useful, so I don't think that's the answer. Maybe individual caches, dynamic or static, or individual cache entries are just cleared the normal 'drupal way' and the LSCache Drupal modules registers those changes and specifically targets what needs to be cleared at the server level, be it a specific page or cache type?

Thanks for your help...
 

iky

New Member
#4
And let me be clear about the phrase "served through memcached" in the second paragraph. What I mean is that obviously the web sever will serve the http request and content of that request, but that the content will be pulled from memcached not dynamically generated by php with some associated mysql query.
 

serpent_driver

Well-Known Member
#5
@iky

I've already answered your questions in my last post. If a page is cached by LScache this page is only HTML, stored as a static file. A static file that only contains HTML (==text) can't execute PHP, MySQL Queries or any other dynamic functions. If a page isn't cached all dynamic functions work as they should.

To understand what LScache does, load a page in browser window, save this page with browser function on your harddisk and open this file with browser or text editor.
 
Top