CMS PostNuke
Cache module
français | english
Navigation
Home
Sitemap
This wiki
This page

The cache module


The cache module is used internally by the other modules (Presseinfo, Newspaper, ProContent, Frontpage...) in order to display faster their pages.
The main functioning schema is the following:

- at first call on a certain page, a cache is created, based on the parameters to the page / parameters in session; this cache is marked as dependent on the status of certain information objects in the database
- in subsequent calls, this created cache is used
- when the objects change in the module, the cache module is informed, and it deletes all caches dependent on the specified object.

The module is responsible for:
- defining the parameters on which the cache depends
- defining the information objects on which the cache depends
- calling the cache module in order to update the cache

The pseudocode for this functions is the following:

in display:
      $cache_params = ...;
      if (isCached($cache_params)) {
        $output = getCache($cache_params);
      } else {
        $output = .... compute display ....
        $objects = ... dependent information objects...;
        cache($output, $cache_params, $objects);
      }
      return $output;

in administration of information objects:
          $object_changed = ... information object identification ...;
          invalidateCache($object_changed);

Technical info


The cache is stored in database, using two tables, one containing the cache itself, and one containing the information objects on which the cache depends.

Frequent errors


The most frequent error that can happen is "stalled cache" - when a older version of a page is displayed from cache. This happens when an information object changes, the page displayed must change, but the cache still contains the old version; most probably, the error is caused by the fact that the cache module was not informed of the object change, thus the old cache is still considered valid, and served at every request.

Please check your code.
Search
Share