This is an old revision of the document!
Use cases
Cache separate views for desktop/mobile users
Add cache vary based on User-Agent string to save to and serve from the correct cache copy.
Cache only for guest visitors
Add cache vary for logged in users, but only cache non-logged in users.
How to enable geolocation for LSCache
https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscache:geoip-support
LSCache supports GEOIP. To enable it, the following steps need to be followed:
- Enable the Geolocation database:
In the LSWS Web Console: General →General settings:→ Enable IP GeoLocation → Yes - Install the GeoIP database (for CentOS users):
yum install Geoip-data
or
yum install GeoIP-GeoLite-data
Also check the installation location
rpm -ql Geoip-data
or
rpm -ql GeoIP-GeoLite-data
It may return the database path as:
/usr/share/GeoIP/GeoIP.dat
In the LSWS Admin Console, configure the database location: General →General settings:→ IP to GeoLocation DB ( enter the database path ). - Install other modules:
yum install GeoIP GeoIP-devel zlib-devel
- Enable GeoIP on Apache Conf Config the same way you do in Apache, by placing the following directive:
GeoIPEnable On
- Use rewrite rules to control redirects:
For example, add the following rewrite rules to your.htaccess
file:
<IfModule LiteSpeed> RewriteEngine on RewriteRule .* - [E=Cache-Control:vary=%{ENV:GEO_COUNTRY}] </IfModule>
You can add rewrite conditions for more specific rules. For example: Show different content or currencies for UK, EU, US, and the rest of the world.
You can also refer to this Maxmind page for rewrite examples.