Hello folks,
I'm one of the core developers of Contao (contao.org), an Open Source CMS and I got pretty interested in caching solutions over the last year.
I have to admit that I always found all these special plugins for Wordpress, Magento and lists of rules for certain pages in .htaccess etc. pretty odd because the HTTP specification actually contains everything needed to create reverse proxy functionality so if your application sends the correct headers etc. you can place any proxy in front of it and you don't need any special plugin or complicated rules. I know that a lot of applications unfortunately don't send these headers but if they did, all you needed to do is to just enable caching and let LiteSpeed read the response headers and cache them accordingly:
<IfModule LiteSpeed>
CacheEnable public /
</IfModule>
Am I right that this would check all responses and consider their cache control headers (expire, max age, shared max age, private etc.)?
At Contao we're working on top of Symfony and for caching purposes we use a combination of bundles but the FOSCache library and bundle (https://github.com/FriendsOfSymfony/FOSHttpCache) being the building block of it. We try hard to really send the correct HTTP response headers and started to move to ESI requests for partials with different caching requirements. This all works pretty nice with using Symfony's built in reverse proxy but obviously this one is pretty basic and slow. The FOSCache library provides support for Varnish but I really like LiteSpeed and thus I was looking into if I can bring support for it to that library as well. I don't really want to bother you with PHP and specific Symfony bundles but I'll link to some of their documentation because the problem is described a few times there already so please bear with me.
When reading through the wiki I found that I can achieve almost everything which is pretty cool There's one issue though I seem to be unable to solve and I guess it's a pretty common one: Varying a cache entry on data stored in the session so we can cache pages of logged in users (e.g. for the same user groups). I guess we all agree that varying on "Cookie" is not the best idea because it would basically render caching useless as every user has its own session and thus have their own cache entries instead of sharing them with other users of the same user group.
I noticed you have a solution to vary on a given Cookie key which is cool but this again would force me update my .htaccess on a regular basis and know exactly what cookies might possibly be relevant. For me as a developer that might even work but it is impossible for regular CMS users. Especially when they start installing lots of bundles/extensions/plugins.
So I tried to find out another solution and I ended up with a "preflight request" as I call it. It's similar to nginx' ngx_http_auth_request_module in case you're familiar with that. Just for splitting up the "Cookie" header into multiple headers instead of checking for authorization. So whenever a request with a "Cookie" or "Authorization" header comes in, before checking if an entry exists in the cache, a preflight request to the application is executed, giving it the possibility to sort of split up the "Cookie" header into other headers that then are "replayed" on the original request which is only then checked for in the cache. This allows to "Vary" on any header you like.
See my illustration and the description on https://github.com/terminal42/header-replay-bundle.
There's even a way to ignore the cache completely in such a case which is important for features such as previewing a page (= same URL so it would load from the cache but if you're logged in you should maybe see staged changes).
Coming to my question now. In Symfony's Reverse Proxy I can code whatever I like because it's PHP so we have support for such a preflight request (that's actually what my bundle with the illustration does). In Varnish there's VCL so you can sort of "code" it yourself and it works as well (you can read more here http://foshttpcache.readthedocs.io/en/stable/user-context.html).
In LiteSpeed, however, I couldn't find any equivalent feature.
Would you be interested in working on that concept as it is a very generic one and absolutely not vendor specific, creating a solution for any developer with that problem?
Thanks in advance, Yanick
I'm one of the core developers of Contao (contao.org), an Open Source CMS and I got pretty interested in caching solutions over the last year.
I have to admit that I always found all these special plugins for Wordpress, Magento and lists of rules for certain pages in .htaccess etc. pretty odd because the HTTP specification actually contains everything needed to create reverse proxy functionality so if your application sends the correct headers etc. you can place any proxy in front of it and you don't need any special plugin or complicated rules. I know that a lot of applications unfortunately don't send these headers but if they did, all you needed to do is to just enable caching and let LiteSpeed read the response headers and cache them accordingly:
<IfModule LiteSpeed>
CacheEnable public /
</IfModule>
Am I right that this would check all responses and consider their cache control headers (expire, max age, shared max age, private etc.)?
At Contao we're working on top of Symfony and for caching purposes we use a combination of bundles but the FOSCache library and bundle (https://github.com/FriendsOfSymfony/FOSHttpCache) being the building block of it. We try hard to really send the correct HTTP response headers and started to move to ESI requests for partials with different caching requirements. This all works pretty nice with using Symfony's built in reverse proxy but obviously this one is pretty basic and slow. The FOSCache library provides support for Varnish but I really like LiteSpeed and thus I was looking into if I can bring support for it to that library as well. I don't really want to bother you with PHP and specific Symfony bundles but I'll link to some of their documentation because the problem is described a few times there already so please bear with me.
When reading through the wiki I found that I can achieve almost everything which is pretty cool There's one issue though I seem to be unable to solve and I guess it's a pretty common one: Varying a cache entry on data stored in the session so we can cache pages of logged in users (e.g. for the same user groups). I guess we all agree that varying on "Cookie" is not the best idea because it would basically render caching useless as every user has its own session and thus have their own cache entries instead of sharing them with other users of the same user group.
I noticed you have a solution to vary on a given Cookie key which is cool but this again would force me update my .htaccess on a regular basis and know exactly what cookies might possibly be relevant. For me as a developer that might even work but it is impossible for regular CMS users. Especially when they start installing lots of bundles/extensions/plugins.
So I tried to find out another solution and I ended up with a "preflight request" as I call it. It's similar to nginx' ngx_http_auth_request_module in case you're familiar with that. Just for splitting up the "Cookie" header into multiple headers instead of checking for authorization. So whenever a request with a "Cookie" or "Authorization" header comes in, before checking if an entry exists in the cache, a preflight request to the application is executed, giving it the possibility to sort of split up the "Cookie" header into other headers that then are "replayed" on the original request which is only then checked for in the cache. This allows to "Vary" on any header you like.
See my illustration and the description on https://github.com/terminal42/header-replay-bundle.
There's even a way to ignore the cache completely in such a case which is important for features such as previewing a page (= same URL so it would load from the cache but if you're logged in you should maybe see staged changes).
Coming to my question now. In Symfony's Reverse Proxy I can code whatever I like because it's PHP so we have support for such a preflight request (that's actually what my bundle with the illustration does). In Varnish there's VCL so you can sort of "code" it yourself and it works as well (you can read more here http://foshttpcache.readthedocs.io/en/stable/user-context.html).
In LiteSpeed, however, I couldn't find any equivalent feature.
Would you be interested in working on that concept as it is a very generic one and absolutely not vendor specific, creating a solution for any developer with that problem?
Thanks in advance, Yanick