This article describes how to enable caching for PrestaShop on a Turbo server.
To enable caching for PrestaShop version 1.7 (or a newer version), use the LSCache Module for PrestaShop. To do this, follow these steps:
X-LiteSpeed-Cache: hit
If you do not see this line in the HTTP response header from the server, then the content was not served from the cache.
To enable caching for PrestaShop version 1.6 (or an older version), follow these steps:
In the directory where you installed PrestaShop, open the .htaccess file in a text editor. You can use one of the text editors in cPanel, or you can log in to your account using SSH and use a command-line editor.
Copy the following text and paste it at the top of the .htaccess file:
<IfModule LiteSpeed> RewriteEngine On RewriteCond %{REQUEST_METHOD} ^GET|HEAD|PURGE$ RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteCond %{REQUEST_URI} !admin123|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>
Save your changes to the .htaccess file. Caching is now enabled for PrestaShop.
To verify that caching is working correctly on your account, you can examine the raw HTTP headers sent between the browser and web server. (To do this, use a browser plugin that displays the raw headers such as Live HTTP headers for Mozilla Firefox, or the Developer Tools feature in Google Chrome.) When content is served from the cache, the server adds the following line to the HTTP response header:
X-LiteSpeed-Cache: hit
If you do not see this line in the HTTP response header from the server, then the content was not served from the cache.
Turbo accounts do not cache static content, such as audio and image files, on the web server. This type of content is cached by client web browsers instead. However, you can specify how long web browsers should cache your static content by using the ExpiresByType directive in the .htaccess file. For example, the following lines instruct web browsers to cache MP3 files for one year (31557600 seconds) and GIF files for 30 days (2592000 seconds):
ExpiresByType audio/mp3 A31557600 ExpiresByType image/gif A2592000
For more information about the ExpiresByType directive, please visit https://httpd.apache.org/docs/2.4/mod/mod_expires.html#ExpiresByType.
For detailed information about LiteSpeed caching, please visit https://docs.litespeedtech.com/lscache.
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.
We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.