LSCache + PrestaShop Configuration

Note: This page describes an easy way to set up simple caching for PrestaShop installations. With the release of LiteSpeed Cache for PrestaShop, though, this solution is now deprecated. Click here for the LiteSpeed Cache for PrestaShop installation and configuration manual.

LSCache, similar to Varnish cache, is a simpler and more efficient page-caching solution built in to LiteSpeed Web Server. When used in conjunction with PrestaShop, you can expect significant performance gains with a quick and easy setup. Cache management is also made significantly easier and more flexible. While the LiteSpeed cache plugin for Prestashop is still in development, rewrite rules can be used to customize LSCache's behavior.

Below are some recommended configurations to enable LSCache and get it working with your PrestaShop site(s).

Configure Server/Virtual-Host-Level Cache Root And Cache Policy

Server/Virtual-Host-level cache storage needs to be configured properly for your environment. Select your server setup from the Web Server Configuration section of our LiteSpeed Cache Installation Guide and follow the instructions to set the server/virtual-host-level cache root and cache policy.

Rewrite Rules

At the top of your .htaccess file, located in the document root of your PrestaShop installation, add the following:

########## Begin - Litespeed cache
<IfModule LiteSpeed>
  RewriteEngine On
  CacheDisable public /
  RewriteCond %{REQUEST_METHOD} ^GET|HEAD|PURGE$
  RewriteCond %{HTTP_HOST} ^(www.)?your_domain_name.com [NC]
  RewriteCond %{REQUEST_URI} !your_admin_folder|404|address|authentication|best-sales|cart|contact|discount|guest-tracking|history|identity|order|password|products-comparison|search|account|friend|login|logout|addresses|contact-us|order-history|my-account|order-confirmation|order-follow|quick-order|credit-slip|password-recovery [NC]
  RewriteCond %{HTTP_COOKIE} !logged|cart [NC]
  RewriteCond %{QUERY_STRING} !nocache [NC]
  RewriteRule .* - [E=Cache-Control:max-age=900]
</IfModule>
########## End - Litespeed cache

Notes

  • The CacheDisable public / directive is used to help protect against globally-enabled caching and is optional. If this directive is not used, the server's global cache settings should be checked to ensure that cache is not enabled globally. Do NOT use CacheEnable public / here as it will enable caching for all URLs belonging to this virtual host, including admin pages.
  • your_domain_name.com is the web address of your PrestaShop site and your_admin_folder is the PrestaShop administration folder name specified during installation. Replace them with your real domain name and admin folder.
  • For any friendly URLs included in the REQUEST_URI configuration line, make sure any corresponding translated (rewritten) URLs are also included. (To view friendly URLs in the PrestaShop administration interface, navigate to Preferences > SEO & URLs.)
  • We recommend using a different domain for your backend such as backend.your_domain_name.com so that you can add/edit/preview a website's content through the admin domain without worrying about these changes being cached and seen by visitors.
  • To get the non-cached version of a page, add the nocache query string to a URL.

For example

https://www.your_domain_name.com/about?nocache
https://www.your_domain_name.com/about?some_other_query_string&nocache

Verify Cache Setup

Look for X-LiteSpeed-Cache: hit in the reply headers. See more detailed directions here.

Deleting Outdated Cache Files Using A Cron Job

Please refer to this wiki to learn how to clean up outdated cache files.

 
litespeed_wiki/cache/no-plugin-prestashop.txt · Last modified: 2017/08/14 19:47 by Lisa Clarke