[dokuwiki] Re: Remove a page from the cache

  • From: Christopher Smith <chris@xxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Tue, 24 Nov 2009 16:34:50 +0000


On 24 Nov 2009, at 14:23, Myron Turner wrote:

Christopher Smith wrote:

There are a couple of short-cuts that will have the same effect.
1. Update the mtime of metadata file. The cached HTML is dependent on the metadata file. If the cache is older than the metadata it won't be valid. You can update metadata by either touching the file or setting some metadata value of your own. This is the best method to use if its only the html that needs to be refreshed - in plugin terms you're calling render() but not handle().

- Chris


Does this mean that calling this function:

 p_set_metadata($id, $data, $render, $persistent);

is effectively the same as touching the meta file?

Kind of. touch simply changes a file's mtime, its content is unaltered. That function is a file update, a side effect of which is to change the file's mtime. Hence, me advocating you write a meaningful metadata key, 'cache' => 'expired'.

And where do these techniques stand with respect to the event processing of PARSER_CACHE_USE:

           $event->preventDefault();
           $event->stopPropagation();



The event has the power to change DokuWiki's cache decision making, by:
- preventing the default cache check,
- removing dependencies from $event->data, or
- overriding the result of DokuWiki's cache validity check

Although, all of the above are possible, it would be a poor event handler that incorrectly overrides an invalid cache object without good reason.

Note. I wouldn't consider using p_set_metadata to expire the cache of the current page, you could have concurrency issues. If you change the metadata before dokuwiki checks for cache validity, you'll be fine. If you change it afterwards, its too late.

- Chris

Other related posts: