Like most caches, LiteMage Cache needs to be periodically cleaned to prevent the cache storage from growing too large. Deleting these files by flushing the cache through Magento could slow down your site and it would instead be preferable to do this cleaning in a separate process. To this end, when the cache is flushed, LiteMage only marks files as “expired” rather than deleting them outright. LiteSpeed Web Server periodically cleans up the storage directory and deletes cache entries that have reached their natural expiration date, but it does not apply to these entries that have been marked as “expired” through flushing. For that you can use our script.
We have included a cleanlitemage.sh
script in the admin/misc
directory of your LSWS installation directory.
This script takes the following input parameters:
-priv <age_mins>
- (Optional) - Determines the maximum age (in minutes) of items stored in the private cache. The default value is 60 minutes. If set, value must be greater than 0. -pub <age_mins>
- (Optional) - Determines the maximum age (in minutes) of items stored in the public cache. The default value is 0, meaning public cache will not be purged. If set, value must be greater than 10.<litemage_cache_dir1> … <litemage_cache_dir9>
- (Required) - Specifies one or more LiteMage cache storage directories separated by spaces. Each directory must contain the /priv
directory.
Note: The values (in minutes) used for -priv
and -pub
should be set higher than Default Private Cache TTL (seconds) and Default Public Cache TTL (seconds) in LiteMage's Configuration settings in the Magento Admin Panel. This will ensure that you are only purging expired files.
Tip: Once you have found a combination of settings that keeps your cache size reasonable, you can then include this script in a cron job to automate the process.