The Console - JCH Optimize Plugin

The Console - JCH Optimize plugin is used to run Command Line Interface (CLI) commands with the Joomla CLI application. One common use for this is for running CRON jobs. These are commands configured to run at scheduled times on your server. Your hosting provider should be able to get you up and running on configuring and using CRON jobs.

This plugin should be enabled on installation, but if you intend to run JCH Optimize commands using the CLI, you should ensure this plugin is enabled.

Using the Joomla CLI Application

As of Joomla 4.0, Joomla comes with a CLI application that you access at /cli/joomla.php, relative to your site's root. So, to use the CLI application, you can run a command like this on the command line:

/path/to/php /path/to/joomla/cli/joomla.php

This command will list information of the usage, options and the available commands registered with the Joomla CLI Application. Typically, to run a command provided by an extension you would run:

/path/to/php /path/to/joomla/cli/joomla.php namespace:command

As you can see, the command consists of a namespace section, which tends to be the name of the extension, and a command, separated by a semicolon. Some commands are also further separated by a semicolon.

The Recache CLI Command

The Recache feature can be run on the command line using the Joomla CLI Application with the Console - JCH Optimize plugin and the jchoptimize:recache command. To run the recache function, you use the following command:

/path/to/php /path/to/joomla/cli/joomla.php jchoptimize:recache [options]

To get a list of all the various options and description, run:

/path/to/php /path/to/joomla/cli/joomla.php help jchoptimize:recache

This will print:

    jchoptimize:recache [options]

        --delete-cache|--no-delete-cache  Delete or do not delete the existing cache first. The default is to delete the cache first.
    -l, --crawl-limit=CRAWL-LIMIT         The maximum number of URLs that will be crawled.
    -c, --concurrency=CONCURRENCY         The number of URLs that will be crawled at the same time.
    -m, --max-depth=MAX-DEPTH             Starting from the base URL, all the URLs found on that page will be crawled then all the URLs found on the crawled pages, and so on. This sets how deep the crawl will extend.
        --live-site[=LIVE-SITE]           The URL to your site, e.g.
    -h, --help                            Display the help information
    -q, --quiet                           Flag indicating that all output should be silenced
    -V, --version                         Displays the application version
        --ansi                            Force ANSI output
        --no-ansi                         Disable ANSI output
    -n, --no-interaction                  Flag to disable interacting with the user
    -v|vv|vvv, --verbose                  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

    jchoptimize:recache will crawl all the configured pages to recache the site with JCH Optimize.
    Usage: php joomla.php jchoptimize:recache


If you already have the live_site value in your configuration.php set to the URL of your site, you don't need to use the --live-site option.


If any of the --crawl-limit, --concurrency, or --max-depth options are omitted, the value set on the Recache Settings section on the General tab of the Options page will be used. Setting them on the command line overrides these values.


If you're still using Joomla 3, then the Console - JCH Optimize plugin won't be installed. However, a CLI script is provided at /cli/jchoptimize_recache.php to run the Recache CLI command using the same options.