[dokuwiki] Re: Content-dependent Purge/Cache
- From: Ben Coburn <btcoburn@xxxxxxxxxxxxx>
- To: dokuwiki@xxxxxxxxxxxxx
- Date: Wed, 10 Jan 2007 16:45:13 -0800
On Jan 10, 2007, at 11:35 AM, Todd Augsburger wrote:
I have a dokuwiki that appears differently to "editors" (those logged
in)
than to the general public. The editors would like to include comments
(on
wiki pages) that will be invisible to the general public.
So I wrote a plugin which handles the comments properly. However,
caching
needs to be turned off for pages which contain these comments, since
they're
user-dependent. My solution (which works) is:
1) A syntax plugin renders the comment as either visible or invisible,
depending on the user, then uses p_set_metadata() to set a flag which
suggests that the page be purged.
2) An action plugin hooks PARSER_CACHE_USE and uses p_get_metadata()
to get
the flag. If set, I then set depends['purge'] = true so that the page
is
refreshed.
[...]
So ... I have 3 specific questions:
1) Is there a better way to accomplish this? (Is there no other way
that the
plugin can request that the page not be cached?)
2) Step 3 seems awkward and inefficient, because I re-read the file
when
it's rarely changed. Is there some other way to tell if the metadata
may
need a refresh?
This may be entirely too clever to work, but what about this.... Use
syntax and action plugins that operate independently (without touching
the metadata).
1) Syntax plugin: Same. Displays notes for users that are allowed to
see them.
2) Action plugin - PARSER_CACHE_USE:
Do not use depends['purge']. Instead, partition the cache by changing
the cache file name if the user is allowed to view notes. Some
pseudo-code:
$cache = $event->data;
if (user can view notes && $cache->ext=='xhtml') {
$cache->cache = $cache->cache . '_notes'; //change cache file path
}
This would partition your cache of 'xhtml' data into the default
'xhtml' cache that does not have notes and the 'xhtml_notes' cache. The
rest happens automatically, so you retain the speed of cached content.
The only obvious down side is that this will double the size of your
'xhtml' cache.
Note: You may also need to do other things to protect the notes, such
as preventing guests from displaying the raw dokuwiki markup for pages.
See disabled actions in the config documentation.
Regards, Ben Coburn
-------------------
silicodon.net
-------------------
--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist
- Follow-Ups:
- [dokuwiki] Re: Content-dependent Purge/Cache
- From: Chris Smith
- References:
- [dokuwiki] Gliffy - visio like plugin
- From: Matt Pascoe
- [dokuwiki] Re: Gliffy - visio like plugin
- From: Galen Johnson
- [dokuwiki] Re: Gliffy - visio like plugin
- From: Andreas Gohr
- [dokuwiki] Re: Gliffy - visio like plugin
- From: Matt Pascoe
- [dokuwiki] Content-dependent Purge/Cache
- From: Todd Augsburger
Other related posts:
- » [dokuwiki] Content-dependent Purge/Cache
- » [dokuwiki] Re: Content-dependent Purge/Cache
- » [dokuwiki] Re: Content-dependent Purge/Cache
- » [dokuwiki] Re: Content-dependent Purge/Cache
- » [dokuwiki] Re: Content-dependent Purge/Cache
- » [dokuwiki] Re: Content-dependent Purge/Cache
- » [dokuwiki] Re: Content-dependent Purge/Cache
- » [dokuwiki] Re: Content-dependent Purge/Cache
- » [dokuwiki] Re: Content-dependent Purge/Cache
- » [dokuwiki] Re: Content-dependent Purge/Cache
- » [dokuwiki] Re: Content-dependent Purge/Cache
- » [dokuwiki] Re: Content-dependent Purge/Cache
- » [dokuwiki] Re: Content-dependent Purge/Cache
- » [dokuwiki] Re: Content-dependent Purge/Cache
- » [dokuwiki] Re: Content-dependent Purge/Cache
- » [dokuwiki] Re: Content-dependent Purge/Cache
- » [dokuwiki] Re: Content-dependent Purge/Cache
- » [dokuwiki] Re: Content-dependent Purge/Cache
- » [dokuwiki] Re: Content-dependent Purge/Cache
wiki pages) that will be invisible to the general public.So I wrote a plugin which handles the comments properly. However, caching needs to be turned off for pages which contain these comments, since they're
user-dependent. My solution (which works) is: 1) A syntax plugin renders the comment as either visible or invisible, depending on the user, then uses p_set_metadata() to set a flag which suggests that the page be purged.2) An action plugin hooks PARSER_CACHE_USE and uses p_get_metadata() to get the flag. If set, I then set depends['purge'] = true so that the page is
refreshed. [...] So ... I have 3 specific questions:1) Is there a better way to accomplish this? (Is there no other way that the
plugin can request that the page not be cached?)2) Step 3 seems awkward and inefficient, because I re-read the file when it's rarely changed. Is there some other way to tell if the metadata may
need a refresh?
- [dokuwiki] Re: Content-dependent Purge/Cache
- From: Chris Smith
- [dokuwiki] Gliffy - visio like plugin
- From: Matt Pascoe
- [dokuwiki] Re: Gliffy - visio like plugin
- From: Galen Johnson
- [dokuwiki] Re: Gliffy - visio like plugin
- From: Andreas Gohr
- [dokuwiki] Re: Gliffy - visio like plugin
- From: Matt Pascoe
- [dokuwiki] Content-dependent Purge/Cache
- From: Todd Augsburger