Configuring the cache

There are several parameters used to finely tune SPIP’s page cache.

Cache longevity

It is essentially a useless act to provide every SPIP template a specific cache duration by using the #CACHE markup tag. This tag is, however, useful for defining a validity duration that is different from SPIP’s default value. In concrete terms, a piece of include code that lists news items from other syndicated sites will benefit from being refreshed more regularly than the default for the rest of the site, perhaps once every hour, for example.

In most cases, it’s better to use a longer cache duration by default, since SPIP will automatically obsolete the cache when changes have been made to any content.

The page cache is defined as 24 hours, which can be modified by changing the constant _DUREE_CACHE_DEFAUT, as in this example where it is assigned to one month (30 days):

define('_DUREE_CACHE_DEFAUT', 24*3600*30);

Cache size

SPIP organises itself so that the cache does not exceed a certain predetermined maximum size, set to 10 MB by default. The global variable $GLOBALS['quota_cache'] is used to change this default value, as shown in this example which sets the upper limit to 100 MB:

$GLOBALS['quota_cache'] = 100;

Cache validity

A final facility is provided for development or debugging reasons, which can be used to modify the operation or usage of the cache. A constant named _NO_CACHE is used for this purpose (or simply use the "NoCache" plugin):

// never use the cache 
// and don't even create the cache files
define('_NO_CACHE', -1); 

// do not use the cache file, 
// but store the results of the calculation in the file cache 
define('_NO_CACHE', 1);

// always use the cache files if they exist
// if they don't, then calculate them
define('_NO_CACHE', 0); 

Author Mark Baber Published : Updated : 12/03/23

Translations : English, français