Coding with SPIP 3.0
SPIP3.0 Technical Documentation

> > > > Configuring the cache

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):

  1. 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:

  1. $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):

  1. // never use the cache
  2. // and don't even create the cache files
  3. define('_NO_CACHE', -1);
  4.  
  5. // do not use the cache file,
  6. // but store the results of the calculation in the file cache
  7. define('_NO_CACHE', 1);
  8.  
  9. // always use the cache files if they exist
  10. // if they don't, then calculate them
  11. define('_NO_CACHE', 0);

Download