Command-Line Reference

Name

jchoptimize:clear-expired — Delete expired files from the cache Joomla

Synopsis

php cli/joomla.php jchoptimize:clear-expired [--time-limit=seconds]

Description

Deletes the optimized files that are older than the Cache lifetime, and the cached pages that use them, then tells you how many it deleted. The JCH Optimize - Delete expired cache scheduled task does the same once a day, so you only need this command to run it from CRON instead. Disable the task then, so it doesn't run twice; see the section called “Delete Expired Cache on a Schedule”.

If your cache storage is APCu, use the scheduled task: the command line doesn't share APCu with your site, so the command stops with an error rather than clean the wrong cache.

On a LiteSpeed server, also use the scheduled task, run from the site: LiteSpeed's cache can't be cleared from the command line, so pages it cached could still link to the deleted files. With the LSCache plugin installed, the command keeps the expired files and tells you so.

Options

--time-limit, -t

The most seconds this run spends checking the cache. If the cache can't be checked in that time, all of it is cleaned instead. The default is 60, and the most is 150. Page caching pauses while the cache is checked.

Example

Delete expired cache every night at 2:30:

30 2 * * * /usr/bin/php /path/to/site/cli/joomla.php jchoptimize:clear-expired --quiet