Even if you don’t use popular CMS scripts like “WordPress” or “PrestaShop”, you can take advantage of the acceleration of your website by using the “LiteSpeed Cache” that we provide as part of our services.
Table of Contents
Basic rule in .htaccess file
<IfModule LiteSpeed>
CacheEnable public
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^GET|HEAD$
RewriteCond %{HTTP_HOST} ^your-domain-name.com [NC]
RewriteRule .* - [E=Cache-Control:max-age=120]
</IfModule>
Note that the above example assumes the cache of the entire website and that it is completely static, i.e. it is a company website, where changes are not made very often, and if they are introduced, it is not critical for the update to take place immediately. In the example above, the refresh occurs at intervals of 120 seconds, so the change will be visible to visitors after 2 minutes.
Explanation of each option from the example:
- CacheEnable Public – Activate Public Cache Usage
- RewriteEngine On – Activate Rewrite Option
- RewriteCond %{REQUEST_METHOD} ^GET|HEAD$ – reading headers
- RewriteCond %{HTTP_HOST} ^your-domain-name.com [NC] – indicate the domain name for the rules
- RewriteRule.* – [E=Cache-Control:max-age=120] – specify how often the cache should be refreshed
Three forms – public cache, private cache, no cache
It is worth remembering that there are three forms of cache use. These are:
- public cache – where we deal with pages that can be considered relatively static, i.e. those whose content does not change very often.
- private cache – in the case when websites are served using SSL and where the accounts of website users / customers and sessions maintained in cookies appear
- no cache – when pages contain forms, the appearance of new content on pages is a critical element, e.g. pages containing news
Emptying Memory Using the Command Line
If you need to force a cache wipe on the server, in addition to the validity time specified in the .htaccess file, you can also use the command issued from the command line during the connection SSH
curl -i -X PURGE http://your-domain-name.com For more information on configuring LiteSpeed Cache using rules in the .htaccess file, see the manufacturer’s documentation:
https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:no-plugin-setup-guidline