Chapter 12. Accompanying Extensions

On WordPress WordPress

On WordPress, JCH Optimize is a single plugin, JCH Optimize (or JCH Optimize Pro), with everything under Settings → JCH Optimize. Two helpers come with it:

The Mode Switcher Pro

A JCH Optimize menu in the admin bar. It switches between Production and Development mode, switches the page cache on or off, links to the settings, shows the cache size and deletes the cache. The page cache goes off and on with the mode while Integrate mode switcher is on, and its own item switches it by itself in either mode. The color of the menu's icon shows the state: green when optimization and the page cache are both on, grey when the page cache is off, orange when only the page cache is on, and red when both are off. The plugin stays active in Development mode, so the menu, the settings and Optimize Images stay available; deactivating the plugin removes the menu with it. You can hide it with Disable Mode Switcher on the Miscellaneous tab. See the section called “Pause JCH Optimize While You Work on Your Site”.

Earlier versions installed it as a "must-use" plugin (wp-content/mu-plugins/jch-optimize-mode-switcher.php), because Development mode deactivated JCH Optimize. An update removes that file.

Scheduled jobs (WP-Cron)

Recache, scheduled image optimization and Page Experience processing run as WordPress scheduled jobs. WordPress runs these when your site has visitors. If your host disables WP-Cron and runs it from the server's CRON instead, they run on that schedule.

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 plugin that handled the form knows when its pages stop showing what the visitor submitted, for example when a guest empties their shopping cart. That plugin, or a small plugin of your own, can then run the jch_optimize_user_post_form_delete_cookie action, and JCH Optimize removes the cookie, so the visitor is served cached pages again from their next page:

do_action('jch_optimize_user_post_form_delete_cookie');

Run 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 run 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 runs jch_optimize_user_post_form when a visitor submits a form, and sets the cookie in response.

Editors can clear the page cache without access to the settings. They find Tools → Page Cache, and Delete Cache in the admin bar's JCH Optimize menu. To let other users do the same, such as Authors, give them or their role the jch_clear_page_cache capability with a role editor plugin. The same users can delete cached pages from another system: see the section called “Delete Cached Pages from Another System”.

On This Page