How to Cache POST when using LSCWP and Guestmode

LiteCache

Active Member
#1
In case you are thinking of switching from OLS to LSWS at some point, I want to point out one of the many differences between the OpenLiteSpeed and LiteSpeed Enterprise web servers.

The LSWS offers the possibility to cache POST requests. The OLS cannot do that. While POST is typically only used for critical requests that primarily involve private matters, even these can be cached without losing sensitive private data. You can abuse POST requests for whatever purpose, although abuse doesn't necessarily mean malicious. This then has more to do with security, so that, unlike GET requests, sensitive data may remain hidden.

In this specific case, it is about caching POST requests when using the LiteSpeed Cache Plugin. For reasons that have not yet been determined, LScache refuses to cache POST requests when using LSCWP (== LiteSpeed Cache Plugin for Wordpress), whereby POST requests are generally set to no-cache by the cache plugin and this is natural from POST also has its justification.

However, there are cases where caching of POST requests is needed. Usually you would have to overwrite the no-cache directive, but this fails if you use guestmode at the same time. The cache plugin's force caching method doesn't seem to work on POST requests. The guestmode is crucial for reasons that cannot be determined so far, because it prevents the caching of POST requests. The LS developers can't really explain that either.....

So whenever you need POST and want to cache it, but don't want to do without the guestmode, use the following code:

Code:
CachePost on
RewriteCond %{REQUEST_URI} ^\/request_url [NC]
RewriteRule .* - [E=cache-control:no-vary]
It is important in this context that the cache is declared as private and request method must be $_POST.
 
Top