This Plugin caches TWiki variables in selected topics for faster page rendering.
Most topics in a typical TWiki installation are rendered within a small deviation in terms of speed. Exceptions are topics that contain a lot of dynamic content. This is mainly caused by CPU or I/O intensive TWikiVariables, such as %SEARCH{}%
and %INCLUDE{}%
.
This Plugin caches all %VARIABLES%
located in a topic so that the topic can get rendered as quickly as one without variables. An outdated cache gets refreshed when a user is looking at a topic; in which case it will take longer to render the page. Time-based refresh can also be disabled in favor of an on-demand cache update. The cache of affected topics can be invalidated based on parent relationship, backlinks and topic includes.
The rendering of TWiki markup to HTML is not cached. That is, user specific HTML rendering based on skin settings is not affected by the caching.
%VARCACHE{}%
variable to the topic you want to cache Parameter | Description | Default![]() |
---|---|---|
updatemsg="..." | Message shown after a cache refresh Note: Use $link to indicate the refresh URL | UPDATEMSG Plugin setting |
"..." orrefresh="..." | Cache refresh period in hours, e.g. maximum age of cache | REFRESH Plugin setting |
cachemsg="..." | Message shown when looking at a cached topic Note: Use $age to indicate the age of cache, $link to indicate the refresh URL | CACHEMSG Plugin setting |
%VARCACHE{}%
variable gets: cachemsg
message when looking at a cached topic
updatemsg
message if the cache has just been updated
%VARCACHE{}%
variable)
?varcache=refresh
URL parameter (usually by following the refresh link in the cache message)
varcache
and topic
(e.g. to show dynamic content properly, such as table sorting, filtering, searching)
VARCACHE_EXCLUDE_
and it will be excluded from caching. For example, to exclude %WIKIUSERNAME%
write %VARCACHE_EXCLUDE_WIKIUSERNAME%
. Make sure to escape all variables that depend on an escaped variable. For example, escape a FORMFIELD variable if it encloses an escaped WIKIUSERNAME: %VARCACHE{"24"}%
%VARCACHE_EXCLUDE_FORMFIELD{ "FirstName" topic="%VARCACHE_EXCLUDE_WIKIUSERNAME%" }%
<varcache_exclude> ... </varcache_exclude>
to exclude sections of a page from caching. Example: %VARCACHE{"24"}%
Cached: %SEARCH{ "." nonoise="on" format="$topic" separator=", " limit="10" }%
<varcache_exclude>
Not cached: %SEARCH{ "%WIKINAME%" nonoise="on" format="$topic" separator=", " limit="10" }%
</varcache_exclude>
Cached: %WEBLIST{}%
This plugin can be configured with preferences settings in Main.TWikiPreferences (site level), a WebPreferences (web level) or in a topic (page level). Do not change the settings here, they are here only to illustrate the default values. To overload, copy the settings to one of the aforementioned topics. On a large site having many webs, it's recommended to set VARCACHEPLUGIN_INVALIDATEONUPDATE none
at the site level to prevent save slowness from happening unknowingly. The current site level setting is undefined, which is the same as include
.
data/debug.txt
)
0
, default: 24
parent
(its parent topic), parent(32)
(its parent topics on parent path up to 32 levels), backlinks
(its backlink topics in current web), include
(its including topics in current web), none
(no invalidation), or a comma-list thereof. none
for webs that have 10K+ topics.
$age
to indicate age of cache, $link
to indicate the refresh URL:
%WIKIUSERNAME%
of the person who refreshed the cache (on demand or by looking at a topic with an expired cache) unless the variable is specifically excluded from caching. %WIKIUSERNAME%
write %VARCACHE_EXCLUDE_WIKIUSERNAME%
.
<varcache_exclude> ... </varcache_exclude>
tags can't be used in included topics; use the VARCACHE_EXCLUDE_
variable prefix in included topics.
VARCACHEPLUGIN_INVALIDATEONUPDATE
to none
for webs that have 10K+ topics.
Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the TWiki server.
VarCachePlugin.zip
in your twiki installation directory. Content: File: | Description: |
---|---|
data/TWiki/VarCachePlugin.txt | Plugin topic |
data/TWiki/VarCachePluginTest.txt | Plugin test topic |
data/TWiki/VarVARCACHE.txt | Variable documentation topic |
lib/TWiki/Plugins/VarCachePlugin.pm | Plugin Perl module |
pub/TWiki/VarCachePlugin/cachetopic.gif | Cache icon 16x16 |
?varcache=refresh
parameter to the URL.
Plugin Author: | TWiki:Main.PeterThoeny![]() |
Copyright: | © 2013-2015 Wave Systems Corp. © 2004-2018 Peter Thoeny, TWiki.org ![]() © 2008-2018 TWiki:TWiki.TWikiContributor ![]() |
Sponsor: | Wave Systems Corp.![]() |
License: | GPL (GNU General Public License![]() |
Plugin Version: | 2018-07-08 |
2018-07-08: | TWikibug:Item7841![]() |
2016-12-14: | TWikibug:Item7764![]() |
2016-01-14: | TWikibug:Item7708![]() |
2015-03-16: | TWikibug:Item7625![]() |
2015-01-09: | TWikibug:Item7568![]() |
2014-02-22: | TWikibug:Item7438![]() |
2013-12-29: | TWikibug:Item7396![]() |
2013-12-09: | TWikibug:Item7396![]() |
2013-12-04: | TWikibug:Item7396![]() |
2012-11-14: | TWikibug:Item7020![]() |
2012-09-07: | TWikibug:Item6837![]() |
2012-04-27: | TWikibug:Item6871![]() <varcache_exclude> tag to exclude parts of page from getting cached |
2011-05-25: | TWikibug:Item6701![]() |
2011-05-24: | TWikibug:Item6730![]() ![]() |
2011-05-01: | TWikibug:Item6701![]() |
2010-04-25: | TWikibug:Item6433![]() |
2010-04-06: | TWikibug:Item5414![]() |
2006-01-06: | Small fix for TWiki 4.0 |
2004-07-16: | Doc improvements (no code change) |
2004-07-15: | Initial version |
TWiki Dependency: | $TWiki::Plugins::VERSION 1.1 (TWiki 4.0, 2006-02-01) |
CPAN Dependencies: | none |
Other Dependencies: | none |
Perl Version: | 5.008 |
Benchmarks![]() |
GoodStyle 99%, FormattedSearch 99%, VarCachePluginTest 208% |
Plugin Home: | http://TWiki.org/cgi-bin/view/Plugins/VarCachePlugin![]() |
Feedback: | http://TWiki.org/cgi-bin/view/Plugins/VarCachePluginDev![]() |
Appraisal: | http://TWiki.org/cgi-bin/view/Plugins/VarCachePluginAppraisal![]() |
Related Topics: VarVARCACHE, VarCachePluginTest, TWikiPlugins, DeveloperDocumentationCategory, AdminDocumentationCategory, TWikiPreferences
I | Attachment | History | Action | Size | Date | Who | Comment |
---|---|---|---|---|---|---|---|
![]() |
cachetopic.gif | r1 | manage | 0.9 K | 2018-07-08 - 07:44 | TWikiAdminUser | Saved by install script |