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

  • From: Chris G <cl@xxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Sat, 18 Dec 2010 15:14:18 +0000

On Sat, Dec 18, 2010 at 01:17:22PM +0000, Christopher Smith wrote:
> 
> 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.
> 
Exactly what I'm seeing, it makes sense I suppose but makes what I want
to do rather difficult.

> 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.
> 
It's difficult because I'm wanting to nest the expansion of the
"<xv>xv1</xv>" within another syntax macro's syntax.  Thus the
easiest/tidiest way to do it is at render time.  I'll think about the
way it's all intended to hang together though and it may be possible to
get the parameter value(s) at render time.

> 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. 
> 
That's what I was trying to do!  :-)

Thanks for the explanation, it accounts for what I'm seeing and it may
help me sort out a solution.

While I'm here I've seen:-

    $renderer->info['cache'] = false;

in a couple of other plugins.  Presumably it stops something caching
something, but what exactly?

-- 
Chris Green
-- 
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist

Other related posts: