This is an old revision of the document!


Use cases

Add cache vary based on User-Agent string to save to and serve from the correct cache copy.

Add cache vary for logged in users, but only cache non-logged in users.

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:

  1. Enable the Geolocation database:
    In the LSWS Web Console: General →General settings:→ Enable IP GeoLocation → Yes
  2. 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 ).
  3. Install other modules:
    yum install GeoIP GeoIP-devel zlib-devel
  4. Enable GeoIP on Apache Conf Config the same way you do in Apache, by placing the following directive:
    GeoIPEnable On
  5. 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:GEOIP_COUNTRY_CODE}]
    </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.

  • Admin
  • Last modified: 2016/09/09 13:36
  • by George Wang