• This web contains the official documentation of the TWiki Release 4.3, code named GeorgetownRelease. It is a read-only web for reference.
• This is an older release, see TWiki-6.0 for the latest release documentation.
Tags:
create new tag
, view all tags

Variable Cache Plugin

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 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.

Syntax Rules and Cache Update Rules

  • Add a %VARCACHE{}% variable to the topic you want to cache
    • It supports these parameters:
      Parameter Description Default
      "..." or
      refresh="..."
      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
      updatemsg="..." Message shown after a cache refresh
      Note: Use $link to indicate the refresh URL
      UPDATEMSG Plugin setting
  • The %VARCACHE{}% variable gets:
    • replaced with the cachemsg message when looking at a cached topic
    • replaced with the updatemsg message if the cache has just been updated
    • removed if caching is not active, e.g. when the topic gets rendered dynamically
  • The cache gets updated on topic view if:
    • the cache does not exist (e.g. after adding the %VARCACHE{}% variable)
    • the cache is older than the cache refresh period (unless refresh if set to 0)
    • the cache is older than the topic (e.g. the topic has been updated)
    • the topic is accessed with a ?varcache=refresh URL parameter (usually by following the refresh link in the cache message)
  • The topic is rendered dynamically without caching when:
    • the topic has URL parameters other than varcache (e.g. to show dynamic content properly, such as table sorting, filtering, searching)
    • the topic is previewed after editing
  • Limitations:
    • The cache is not user specific. For example, all users see the expanded %WIKIUSERNAME% of the person who refreshed the cache (on demand or by looking at a topic with an exired cache)

Plugin Settings

Plugin settings are stored as preferences variables. To reference a plugin setting write %<plugin>_<setting>%, i.e. %VARCACHEPLUGIN_SHORTDESCRIPTION%

  • One line description, is shown in the TextFormattingRules topic:
    • Set SHORTDESCRIPTION = Cache TWiki variables in selected topics for faster page rendering

  • Debug plugin: (See output in data/debug.txt)
    • Set DEBUG = 0

  • Default refresh period in hours. No automatic refresh: 0, default: 24
    • Set REFRESH = 24

  • Cache help messages. Use $age to indicate age of cache, $link to indicate the refresh URL:
    • Set CACHEMSG = This topic was cached $age ago ([[$link][refresh]])
    • Set UPDATEMSG = This topic is now cached ([[$link][refresh]])
    • #Set CACHEMSG = Refresh cache
    • #Set UPDATEMSG = Refresh cache

Plugin Installation Instructions

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.

  • Download the ZIP file from the Plugin web (see below)
  • Unzip 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
  • TWiki 4.0 and up: Run the configure script to enable the Plugin
  • Test if the installation was successful:
    • Visit the VarCachePluginTest topic, it contains a nested search
    • Click on the refresh link or append a ?varcache=refresh parameter to the URL

Plugin Info

Plugin Author: TWiki:Main/PeterThoeny
Copyright: © 2004-2010, Peter Thoeny, Twiki, Inc.
License: GPL (GNU General Public License)
Plugin Version: 2010-04-06
Change History:  
2010-04-06: Support for plugins that dynamically add JavaScript and CSS using TWiki::Func::addToHEAD(); added VarVARCACHE variable documentation topic; support nameless parameter for refresh time; fixed typo in UPDATEMSG plugin setting name
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.005
TWiki:Plugins/Benchmark: 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

-- TWiki:Main/PeterThoeny - 2010-04-06

Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2010-04-06 - PeterThoeny
 
Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon  
This site is powered by the TWiki collaboration platform Powered by Perl This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback