[dokuwiki] Re: Caching, what does ~~NOCACHE~~ actually do, it doesn't seem to force reprocessing

  • From: Christopher Smith <chris@xxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Sat, 18 Dec 2010 13:17:22 +0000

On 18 Dec 2010, at 11:23, Chris G wrote:

> OK, maybe I'm misunderstanding what ~~NOCACHE~~ does but it's not doing
> what I was expecting anyway.
> 
> I have a test page as follows:-
> 
>    ~~NOCACHE~~
> 
>    Name is: <xv>xv1</xv>
> 
>    xx
> 
> I have a (fairly trivial at the moment) plugin called xv which handles
> the "<xv>xv1</xv>".  
> 
> If I change the test page (by adding or deleting one of those x at the
> bottom) then, as expected, the plugin's render() function is called
> again. With the ~~NOCACHE~~ the render() function is called *every* time
> I go to the page, even if I haven't changed it.  So far so good.
> 
> However the plugin's handle() function *isn't* called again unless I
> change the data, the ~~NOCACHE~~ has no effect on this.
> 
> Is there any way that I can force the plugin's handle() function to be
> called every time the page is loaded?  If there isn't then using the
> link parameters is very difficult because calling the same page with
> different parameters won't call the handle() function and one can't
> process the changed paramters.
> 

Instructions are a dokuwiki representation of the wiki text.  If the wiki text 
hasn't changed the instructions shouldn't change.  Following on from this, 
~~NOCACHE~~ affects the caching of the html generated by the render function.

Ideally, if you're calling a page with parameters, those parameters should be 
handled in the render() method.  If that won't work for you, add an action 
component to your plugin that handles caching events and can extend caching 
logic to correctly determine when cached instructions can be used and when the 
instructions can be regenerated.

Note, generating instructions is one of the most expensive (both in time and 
memory) that dokuwiki does.  If you can handle stuff in render() its by far the 
better place to do it.  In the vast majority of cases it should be possible to 
organise things in such a way that handle() contains all processing that needs 
to be done once for a given set of wiki text and render() does the rest. 

- Chris

Other related posts: