How to enable caching for PrestaShop on Turbo Web Hosting

This article describes how to enable caching for PrestaShop on a Turbo Boost or Turbo Max Web Hosting account.

The information in this article is specific to PrestaShop. For general information about caching on Turbo Boost and Turbo Max Web Hosting accounts, please see this article.
Optimize your site quickly and easily with the A2 Optimized plugin! Instead of manually editing configuration files, you can configure caching and much more from one convenient interface. For more information, please see this article.

Enabling caching for PrestaShop

To enable caching for PrestaShop on a Turbo Boost or Turbo Max Web Hosting account, follow these steps:

  1. Log in to PrestaShop as the administrator.
  2. On the left-side pane, click Modules and Services.
  3. Under MODULES LIST, in the search text box, type a2.
  4. The A2 Hosting with TurboCache module appears. If the module is not installed:
    • Click Install.
      If you receive a message about module verification, click Proceed with the installation.
    • If you install PrestaShop using Softaculous, the A2 Hosting with TurboCache module is automatically installed and enabled.
    • After the TurboCache module is installed and enabled, you do not need to do any additional module configuration.
  5. 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.

    If the .htaccess file does not exist, create it.
  6. Copy the following text and paste it at the top of the .htaccess file:

    <IfModule LiteSpeed>
        CacheEnable public
        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>
    
    • These caching configuration directives must be at the top of the .htaccess file.
    • You only need to include the HTTP_HOST configuration line if you host more than one domain in the public_html directory (such as your primary domain and a subdomain). Replace example.com with the domain name for which you want to enable caching.
    • In the REQUEST_URI configuration line, replace admin123 with the PrestaShop administration folder name that you specified during the installation process.
    • For any friendly URLs you include in the REQUEST_URI configuration line, make sure you also include any corresponding translated (rewritten) URLs. (To view friendly URLs in the PrestaShop administration interface, click Preferences and then click SEO & URLs.)
    • The QUERY_STRING configuration line enables you to see the non-cached version of any page by adding nocache to a query string in the URL. For example, to view the non-cached version of http://example.com/mypage, you could add ?any_field=any_value&nocache to the end of the URL.
  7. Save your changes to the .htaccess file. Caching is now enabled.

    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.

More Information

For detailed information about LiteSpeed caching, please visit http://www.litespeedtech.com/support/wiki/doku.php?id=litespeed_wiki:litespeed:cache.

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.