Rewrite Rules

Control cache behavior by setting environment variables.
NOTE: X-LiteSpeed-* cache related response headers will overrule any storage settings, if applicable.

Syntax:

RewriteRule url1 - [E=cache-control:value1,E=cache-control:value2]
RewriteRule url2 - [E=cache-vary:value1,E=cache-control:value2]

Environment variables can have the following keys
cache-control/cache-ctrl

Regular cache-control directives:
RewriteRule .* - [E=cache-control:max-age=300]
RewriteRule .* - [E=cache-control:private,max-age=300]

Flush private cache:
RewriteRule /flush_cache - [E=cache-control:flush]
You cannot flush the public cache through rewrite rules.

Append a vary string to a cache object key directly:
RewriteRule url2 - [E=cache-control:vary=vary_value]
This directly appends vary_value to a cache key and a CGI environment variable
example: cache-control:vary=ismobile

Cache-Vary

Cache objects vary based on cookie values, this has the same effect as the X-LiteSpeed-Vary response header, the difference is that it only applies for the current request and it is not persistently associated with that URL.

cache-vary:<cookiename>
For example: cache-vary:isloggedin

Examples:
Cache response for 5 minutes (300 seconds).
RewriteRule .* - [E=cache-control:max-age=300]
RewriteRule HTTP_USER_AGENT mobi [E=cache-control:vary=ismobile]

ESI
Rewrite Rules can also control the ESI engine for a request. To turn on the ESI engine for a request:
RewriteRule .* - [E=esi_on:1]

To turn off the ESI engine for a request:
RewriteRule .* - [E=esi_on:0]

Login Conflicts
If there are multiple web applications used for a single site, different cache varies should be used for login purposes to prevent cache conflicts. More information on this can be found here.