-
Notifications
You must be signed in to change notification settings - Fork 61
LiteSpeed support #444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LiteSpeed support #444
Changes from all commits
d065005
b9d4bef
8e627ab
888f2ed
5c547fa
864bf88
190d39a
53b77a4
ea3a3dc
6d466f1
5060661
515a3f6
9d19daf
8954738
bdb151f
ae148ae
55dbb32
773f9e1
13ac037
b154a88
d072524
0ffc8f6
9e9e8b1
58fffce
c9a7908
8972446
3e88831
1fa197c
6d85708
e6f1f56
1c66c58
5faba60
9aea459
d6c23be
3ca287b
0c977c4
8061f40
595bc28
292e1f6
b14416b
8b6b30a
3e934af
c6def7b
5f160db
9cd041e
1965229
3446a94
9f7da19
4a463d7
08a2e61
1ddf540
5f27838
00f0d34
7377f78
ea56c81
46e3742
238377e
2c8d102
df5a9d8
45962f6
b92e8f0
8def743
9faed6a
8566017
c010741
48ed17d
0ff8676
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
.. _litespeed configuration: | ||
|
||
LiteSpeed Configuration | ||
----------------------- | ||
|
||
Below you will find detailed LiteSpeed configuration recommendations for the | ||
features provided by this library. | ||
|
||
Preamble | ||
~~~~~~~~ | ||
|
||
First of all, let's get one thing straight here: You'll find a lot of documentation | ||
and noise around LiteSpeed cache on the Internet, mostly involving plugins, specifically the | ||
Wordpress one. You **don't** need any plugin to benefit from LiteSpeed cache! | ||
As long as you follow the HTTP specification regarding the caching headers, you can use it as | ||
a general reverse proxy just like NGINX or Varnish. | ||
|
||
LiteSpeed comes in two different variants: | ||
|
||
* OpenLiteSpeed (OLS) - the open source product with less features | ||
* LiteSpeed Web Server (LSWS) - the enterprise version with more features and professional support | ||
|
||
The caching module implementations are different and thus have to be configured differently. | ||
Currently, OLS does support cache tagging and cache tag invalidation and LSWS does not. However, LSWS supports ESI | ||
whereas OLS does not. | ||
|
||
So before you start configuring the server, make sure you know which version of LiteSpeed you are using. | ||
|
||
.. note:: | ||
|
||
Any LiteSpeed setup works in a single node web server environment only. If you are targeting a multi | ||
node setup you might want to consider switching to :ref:`Varnish <varnish configuration>` which has excellent | ||
support for this already built-in in this library. | ||
|
||
|
||
Configuring OpenLiteSpeed | ||
~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. note:: | ||
|
||
You need at least OpenLiteSpeed version 1.4.47 | ||
|
||
OLS does not support different caching settings depending on ``.htaccess`` settings and different paths. | ||
If you need that, you have to go with LSWS instead. | ||
Thus, OLS has to be configured as follows on server or vHost level:: | ||
|
||
module cache { | ||
# This enables the public cache | ||
enableCache 1 | ||
|
||
# This disables the private cache | ||
enablePrivateCache 0 | ||
|
||
# This enables the public cache | ||
checkPublicCache 1 | ||
|
||
# This disables the private cache | ||
checkPrivateCache 0 | ||
|
||
# Also consider the query string in caches | ||
qsCache 1 | ||
|
||
# Disable checking for a cached entry if there's a cookie on the request | ||
reqCookieCache 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't support user context caching with litespeed, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right. User context caching requires some kind of preflight request to the app to find out the context which requires implementation in the proxy. |
||
|
||
# We ignore request Cache-Control headers | ||
ignoreReqCacheCtrl 1 | ||
|
||
# Must be disabled, this tells LS to check the Cache-Control/Expire headers on the response | ||
ignoreRespCacheCtrl 0 | ||
|
||
# We don't cache responses that set a cookie | ||
respCookieCache 0 | ||
|
||
# Configure the maximum stale age to a sensible value for your application | ||
# The maxStaleAge defines a grace period in which LS can use an out of date (stale) response while checking on a new version | ||
maxStaleAge 10 | ||
|
||
# Make sure we disable expireInSeconds because it would override our Cache-Control header | ||
expireInSeconds 0 | ||
|
||
# If you want to use cache invalidation by cache tags, configure the general PURGE endpoint here. | ||
# By default, this library is configured to use "/_fos_litespeed_purge_endpoint". If you'd like to | ||
# have a different one, configure it here accordingly and make sure you configure the same URI | ||
# in the library itself (see further down this page). Also make sure you don't overlook trailing slashes here! | ||
purgeuri /_fos_litespeed_purge_endpoint | ||
|
||
# Enable the module | ||
ls_enabled 1 | ||
} | ||
|
||
That's all you need. Of course you might want to adjust certain values to your needs. | ||
Also refer to the OLS docs if you need more details about the different configuration values. | ||
|
||
Configuring LiteSpeed WebServer | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. warning:: | ||
|
||
Unfortunately LSWS does currently not support invalidating cache tags. | ||
|
||
Configuring FOSHttpCache to work with LiteSpeed | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Because LiteSpeed does not support a multi node setup configuring the proxy client is pretty straight forward if | ||
you serve your application only on one domain:: | ||
|
||
use FOS\HttpCache\ProxyClient\HttpDispatcher; | ||
use FOS\HttpCache\ProxyClient\LiteSpeed; | ||
|
||
$servers = ['127.0.0.1']; | ||
$baseUri = 'example.com'; | ||
$httpDispatcher = new HttpDispatcher($servers, $baseUri); | ||
|
||
$litespeed = new LiteSpeed($httpDispatcher); | ||
|
||
If you need multiple domains, make your ``$baseUri`` an array like so:: | ||
|
||
use FOS\HttpCache\ProxyClient\HttpDispatcher; | ||
use FOS\HttpCache\ProxyClient\LiteSpeed; | ||
|
||
$servers = ['127.0.0.1']; | ||
$baseUris = ['example.com', 'foobar.com']; | ||
$httpDispatcher = new HttpDispatcher($servers, $baseUris); | ||
|
||
$litespeed = new LiteSpeed($httpDispatcher); | ||
|
||
|
||
If you configured your LiteSpeed instance to use a different ``purgeuri`` than ``/_fos_litespeed_purge_endpoint`` also | ||
make sure to pass the configured URI like so:: | ||
|
||
use FOS\HttpCache\ProxyClient\HttpDispatcher; | ||
use FOS\HttpCache\ProxyClient\LiteSpeed; | ||
|
||
$servers = ['127.0.0.1']; | ||
$baseUris = ['example.com', 'foobar.com']; | ||
$httpDispatcher = new HttpDispatcher($servers, $baseUris); | ||
|
||
$litespeed = new LiteSpeed($httpDispatcher, ['purge_endpoint' => '/your-uri'); | ||
|
||
Cache Tagging | ||
~~~~~~~~~~~~~ | ||
|
||
If you want to use cache tagging please note that you cannot use the default settings of the ``ResponseTagger`` (which | ||
by default uses ``X-Cache-Tags``) but instead you have to configure it to ``X-LiteSpeed-Tag`` like so:: | ||
|
||
use FOS\HttpCache\ResponseTagger; | ||
use FOS\HttpCache\TagHeaderFormatter; | ||
|
||
$formatter = new CommaSeparatedTagHeaderFormatter('X-LiteSpeed-Tag'); | ||
$responseTagger = new ResponseTagger(['header_formatter' => $formatter]); | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.