User Tools

Site Tools

Cron job controlled JotCache scripts

For JotCache ver.4.x are available two basic scripts (located in directory /administrator/components/com_jotcache/cron) :

  • Page cache cleaning (garbage collection) - cron.php
  • Recaching - cron_recache.php


Page cache cleaning

Cache cleaning is necessary activity which have to be performed on the site because during longer time of cache operation steady increases number of expired cached pages files. In spite of rewriting/update some cached files in file system still remains orphaned files.

Function of this script is similar to JotCache plugin Autoclean feature but cache cleaning is not performed based on site visitor request and selected time period. With the script is done cache cleaning in separate server thread based on initiation of OS cron event.

Cron controlled cache cleaning is recommended for medium and large web sites because of faster response to visitors requests (with no additional time for cleaning activity).


Pages which content on the site was changed during active cache time (before expiration) can be written into cache with new updated content either with deleting of related cached content and consequent page request on frontend or using separate frontend request causing page recache (cached page file update).

Function of recache script is same as Recache features on Administrator JotCache Management View. Inside the script execution are used the same Jotcache plugins (recache, crawler) as in the backend but without (time & process) limitations of browser controlled operation.

The recache script can be adjusted for different functions - recache of existing cached pages or crawling the site starting from homepage to pages linked in given crawl depth. It is also possible to derive from cron_recache.php script template multiple dedicated execution scripts which can run under different cron job settings.

Script preparation

Both scripts cron.php as well as cron_recache.php are code templates which have to be customized for each web site.

Follow the introductory steps :

  1. create new directory with cryptic name outside public accessible part of server file system
  2. rename scrip file with another cryptic name and move it to new created directory
  3. adjust script named constant JPATH_BASE to exactly fit the full path to Joomla document root on the server (e.g. for Apache server can be found in Joomla Administrator System Information/PHP Information - Apache Environment DOCROOT).
  4. (for recache scripts) set cron job run conditions inside script code (some detailed description included in script template)
  5. set cron job definition in server cron table direct or using provider CPanel. Details of cron job settings are given on page How to add jobs to cron or in server documentation.