DEPRECATION WARNING
This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.
EXT: Cache cleaner¶
Author: | Kasper Skårhøj |
---|---|
Created: | 2002-11-01T00:32:00 |
Changed: | 2013-12-08T20:13:43 |
Classification: | cachecleaner |
Keywords: | forAdmins, forIntermediates |
Author: | François Suter |
Email: | typo3@cobweb.ch |
Info 4: | |
Language: | en |
EXT: Cache cleaner - cachecleaner
EXT: Cache cleaner¶
Extension Key: cachecleaner
Language: en
Keywords: forAdmins, forIntermediates
Copyright 2009-2013, François Suter, <typo3@cobweb.ch>
This document is published under the Open Content License
available from http://www.opencontent.org/opl.shtml
The content of this document is related to TYPO3
- a GNU/GPL CMS/Framework available from www.typo3.org
Table of Contents¶
`Introduction 3 <#__RefHeading__494_1805741445>`_
`Installation 4 <#__RefHeading__502_1805741445>`_
`Administration 5 <#__RefHeading__508_1805741445>`_
Configuring the cache cleaner 5
`Known problems 7 <#__RefHeading__516_1805741445>`_
`To-Do list 8 <#__RefHeading__518_1805741445>`_
Introduction¶
What does it do?¶
This extension provides a new submodule for the lowlevel cleaner tool, designed to delete obsolete records from the various TYPO3 cache tables. It can also be used to delete records from any table based on a certain age limit.
Since TYPO3 CMS 4.6, a similar feature is included in the Core as a Scheduler task (see "Compatibility" in the "Installation" chapter). As such this extension is no longer actively developed.
Credits¶
The development of this extension was sponsored by Manpower SA (Switzerland).
Questions?¶
If you have any questions about this extension, please ask them in the TYPO3 English mailing list (typo3.english), so that others can benefit from the answers.
Installation¶
Once the extension is downloaded and installed, the new tool is available for use with the lowlevel_cleaner CLI script, but it must still be properly configured (see “Administration” below).
Extension configuration¶
There's a single configuration option available.
debug : check this box to have the cache cleaner log its actions into the Developer's Log. This may be convenient for checking what the cache cleaner when it is not being run manually. Note that to actually log anything you will need a dev-logging extension, such as “devlog”.
Compatibility¶
The functionality of this extension is provided by the TYPO3 CMS Core itself since version 4.6, by the "Table garbage collection" task of the Scheduler.
The configuration of the Scheduler task uses a similar syntax. Only the "location" is different. Instead of:
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cachecleaner']
use:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']['tx_scheduler_TableGarbageCollection']['options']['tables']
Administration¶
Running the cache cleaner¶
Running lowlevel scripts¶
If you have never run the lowlevel_cleaner scripts before, you should first take a look at some of the documentation available on this topic:
- the
HOWTO\_clean\_up\_TYPO3\_installations.txt
file provided by the lowlevel system extension (typo3/sysext/lowlevel
); - very complete articles written by Michiel Roos in his blog:
Cache cleaner options¶
The cache cleaner script provides the following command-line options:
--optimize¶
Option
--optimize
Description
Runs the OPTIMIZE command on all tables after having cleaned them up.
Note: this will work only with MySQL. Don't use this option if you're running TYPO3 with a different database system.
--tables table_names¶
Option
--tables table_names
Description
Restricts the clean up to only the given tables (comma-separated list) instead of all the configured tables (see “Configuring the cache cleaner” below).
If a table is given that is not configured, it will be ignored.
Example:
Here's an example of command-line call to the cache cleaner:
/usr/local/bin/php /var/www/mysite/typo3/cli_dispatch.phpsh lowlevel_cleaner tx_cachecleaner_cache -r --AUTOFIX -i --optimize --tables cache_hash
The paths to the PHP executable and the cli dispatch script have to be adapted of course.
The “-r” option indicates that the script should actually be run and the “--AUTOFIX” option indicates that the clean up should be applied. The “-i” option makes the process interactive, which means that the user will be queried for confirmation for every table.
The “--optimize” option will ensure that the MySQL-specific OPTIMIZE command will be run on each table after the clean up.
Lastly the “--tables” option restricts the actual run to cleaning up
only the cache\_hash
table.
Configuring the cache cleaner¶
Before running this tool, it is necessary to configure it. The cache
cleaner provides an example configuration in the
configuration\_sample.php
file. It is reproduced here:
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cachecleaner'] = array(
'tables' => array(
'cache_pages' => array(
'expireField' => 'expires'
),
'cache_hash' => array(
'dateField' => 'tstamp',
'expirePeriod' => '7d'
),
'sys_log' => array(
'dateField' => 'tstamp',
'expirePeriod' => '1m'
)
)
);
The configuration is a list of all tables that should be cleaned up. For each table, you have to define whether it has an expiry field (i.e. a field containing an already calculated expiration date) or if the cleaner has to rely on a simple date field, with an age limit.
expireField¶
Key
expireField
Type
string
Description
Name of the field that contains an expiry date. This will often be “expire” or “expires”.
dateField¶
Key
dateField
Type
string
Description
When a table has no explicit expiry field, one can define a datetime field to be used instead. This will be used in combination with the expirePeriod property described below.
expirePeriod¶
Key
expirePeriod
Type
integer/string
Description
Used to define a period after which a record should be considered obsolete and thus deleted. This can be a simple number, in which case it is considered to be a number of days. It can also be a number followed by one of the following: “h” for “hour”, “d” for “day”, “w” for “week” or “m” for “month”.
Examples:
- 5 => 5 days
- 3h => 3 hours
- 6d => 6 days
- 2w => 2 weeks
- 6m => 6 months
Any record whose “dateField” is older than this period of time will be deleted.
Going back to the sample configuration shown above, it means that the
cache\_pages
table will be cleaned up according to the
existing “expires” field. The cache\_hash
table, on the
contrary, has no such field. Instead age calculations will be based on
the “tstamp” field and any record older than 7 days will be deleted.
The same for the sys\_log
table, but for a period of 1 month.
The configuration can be written in the localconf.php
file or
in some extension's ext\_localconf.php
. The configuration
cache must be cleared after any change, as usual.
If no tables are configured, the script will output a message to that effect.
What tables to clean up?¶
As its name implies, this extension is mostly targeted at clearing up
old entries in TYPO3's various cache tables (or those of other
extensions, like RealURL). However there are also quite a few other
tables where data accumulates without limit. It is a good practice to
remove old entries at regular intervals from such tables too. Good
candidates are sys\_log
and sys\_history
, or any such
kind of logging tables.
Post-flight check¶
Just like the other lowlevel_cleaner tools, this script is meant to be run at some fixed time via a cron job, ideally when traffic on the web site is low. This will most likely happen when nobody is watching. There are several possibilities for checking what happened at a later point:
- write the command-line ouput of the lowlevel_cleaner into a log file;
- enable the debug option and check out the Developer's Log;
- check out the Log module in the TYPO3 backend. Some general information about execution of the cache cleaner is written there. This logging cannot be disabled, contrary to the debug logging.
Known problems¶
None to date. Please report any problem to the TYPO3 English mailing list (typo3.english) or submit a bug report to the extension's bug tracker (http://forge.typo3.org/projects/extension- cachecleaner/issues).