Chapter 12. Accompanying Extensions

Abstract

What each part of JCH Optimize does: the Joomla component, plugins and administrator modules, and the WordPress plugin and its helpers. Useful when you look through your list of installed extensions or plugins and wonder what each one is for.

On Joomla Joomla

The pkg_jchoptimize package installs these extensions together. Leave them all enabled unless this section says otherwise; uninstalling the package removes them together.

Table 12.1. Extensions installed on Joomla
ExtensionTypeEdition
JCH OptimizeComponentFree and Pro
System - JCH OptimizePluginFree and Pro
System - JCH Optimize Page CachePluginFree and Pro
System - JCH Optimize Administrator MenuPluginFree and Pro
User - JCH Optimize User StatePluginFree and Pro
Console - JCH OptimizePluginPro
Task - JCH OptimizePluginPro
Web Services - JCH OptimizePluginPro
JCH Optimize Mode SwitcherAdministrator moduleFree and Pro
JCH Optimize Dashboard Icons, JCH Optimize Copyright, AI-Assisted OptimizationAdministrator modulesFree and Pro; AI-Assisted Optimization is Pro

The System - JCH Optimize Plugin

Does the optimizing. When Joomla has built a page, this plugin takes the finished HTML, optimizes it and hands it back to Joomla to send to the visitor. It also answers the reports sent by Page Experience and the one-time verification request made when a site is enrolled for AI-assisted optimization. All its settings are in the component.

Disabling this plugin stops all optimization. To do that temporarily, use the Mode Switcher instead, which also clears the cache when you switch back.

Ordering the JCH Optimize Plugin

Because it works on the finished page, this plugin must run after all other plugins that change the page, and before any page cache plugin, so the cache stores the optimized page. It is placed correctly when you install or update JCH Optimize. If you install other plugins or change the plugin order, click Order Plugin in the dashboard's Utility Tasks to put it back in place.

The System - JCH Optimize Page Cache Plugin

The page cache. It stores each optimized page and sends the stored copy to the next visitors, which greatly reduces your server's response time. It runs after the System - JCH Optimize plugin, so what it stores is already optimized. Logged-in users are never served cached pages.

Switch it on or off with the Mode Switcher, or in Joomla's plugin manager; configure it on the Page Cache tab of the settings page (see the section called “Page Cache Tab”). Keep only one page cache plugin enabled; if you prefer another, see the section called “Use a Different Page Cache Plugin”.

Noteworthy Features

Serve Cached Pages as Static Files Pro

Saves cached pages as plain files that the web server sends directly. See the section called “Going Further: Serving Pages Without PHP”. It sets a small cookie for logged-in users so they can be recognized without starting Joomla.

Excluding form users

When a visitor submits a form (a contact form, adding to a cart), the page they see next is usually meant for them alone. JCH Optimize sets a small cookie when a form is submitted and stops serving that visitor cached pages until the cache expires, while everyone else still gets them. Turn it off with Exclude form users if your site submits forms in the background (for example with Ajax) and doesn't need it.

An extension can serve the visitor cached pages again sooner, for example after they empty their cart; see the section called “Serving Form Users Cached Pages Again”.

The System - JCH Optimize Administrator Menu Plugin

Hides JCH Optimize's pages, in Joomla's administrator menu and on JCH Optimize's dashboard, from users whose permissions don't open them. A user who can only clear the cache sees Page Cache and nothing else. Without this plugin every page is listed for every user who can open JCH Optimize, and the pages they can't use answer with an error. It is a plugin of its own so that it stays enabled in Development mode, which disables the System - JCH Optimize plugin.

The User - JCH Optimize User State Plugin

Sets and removes the small cookies that tell the page cache a visitor is logged in or has submitted a form, using the cookie settings in Joomla's Global Configuration. Keep it enabled.

Serving Form Users Cached Pages Again

With Exclude form users on, a visitor who submits a form isn't served cached pages until the page cache lifetime has passed. Only the extension that handled the form knows when its pages stop showing what the visitor submitted, for example when a guest empties their shopping cart. That extension, or a small plugin of your own, can then trigger the onJchOptimizeUserPostFormDeleteCookie event, and this plugin removes the cookie, so the visitor is served cached pages again from their next page:

use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Event\Event;

// Joomla loads user plugins only for some requests, such as logging in
PluginHelper::importPlugin('user');
Factory::getApplication()->getDispatcher()->dispatch(
    'onJchOptimizeUserPostFormDeleteCookie',
    new Event('onJchOptimizeUserPostFormDeleteCookie')
);

Trigger it before the page is sent, during the request that empties the cart, for example. It does nothing for a visitor who hasn't got the cookie. Only trigger it when the visitor's pages are the same as everyone else's again, since they will be served the pages cached for all guests.

JCH Optimize itself triggers onJchOptimizeUserPostForm when a visitor submits a form, and this plugin sets the cookie in response.

The Console - JCH Optimize Plugin

Adds JCH Optimize's commands to Joomla's command-line application, so you can delete expired cache and, in JCH Optimize Pro, run Recache, image optimization and Page Experience processing from your server's CRON. The commands are described in Command-Line Reference.

Using the Joomla CLI Application

Joomla's command-line application is the file cli/joomla.php in your site's folder. You run it with PHP, followed by the command:

$ php /path/to/site/cli/joomla.php jchoptimize:recache

Run it without a command to list every available command, or with help and a command name for that command's options:

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

Because a command run from CRON isn't part of a visit to your site, JCH Optimize doesn't know your site's address. Give it with --live-site=https://www.example.com/, or set $live_site in Joomla's configuration.php.

Tip

Your hosting control panel usually has a Cron Jobs page where you can add these commands. Use the full path to PHP that your host gives you, and add --quiet so CRON doesn't email you the output every time.

The Task - JCH Optimize Plugin

Adds JCH Optimize's task types to Joomla's Scheduled Tasks, so they run without setting up CRON:

The Web Services - JCH Optimize Plugin Pro

Adds JCH Optimize's addresses to Joomla's Web Services, so another system can delete cached pages: all of them, or the pages it lists. Installing the Pro package enables it. Disable it to switch these addresses off. See the section called “Delete Cached Pages from Another System”.

The JCH Optimize Mode Switcher Module

Sits in the status bar at the top of every administrator page. Its menu:

Its color shows the state at a glance:

Color: Green
JCH Optimize: On
Page cache: On
Color: Grey
JCH Optimize: On
Page cache: Off
Color: Orange
JCH Optimize: Off
Page cache: On
Color: Red
JCH Optimize: Off
Page cache: Off

Page Cache Integration

Which page cache plugin the Mode Switcher controls, and whether it follows the mode, is set on the Page Cache tab of the settings page. See the section called “Use a Different Page Cache Plugin”.

Further Configuring the Mode Switcher Module

The module shows each user what their permissions allow. Users who can change the settings (Configure Options) get the whole menu. Users who can only clear the cache (Clear Cache) get the size of the cache and Delete Cache. Everyone else doesn't see the module. To move it or hide it for everyone, go to System → Manage → Administrator Modules, search for JCH Optimize Mode Switcher and open it.

The Dashboard Modules

The panels of JCH Optimize's dashboard are administrator modules placed on the component's dashboard: one JCH Optimize Dashboard Icons module for each panel of icons, the Copyright module and, in Pro, the AI-Assisted Optimization module, which is placed first. Use the gear icon on a panel to edit, move or hide it; see the section called “The Dashboard” for what each panel contains.

Note

If a panel has disappeared from the dashboard, look for it in System → Manage → Administrator Modules and check that it is published in the position cpanel-com-jchoptimize-cpanel.