CacheChooserAddOn

Chair for Computer Aided Medical Procedures & Augmented Reality
Lehrstuhl für Informatikanwendungen in der Medizin & Augmented Reality

THIS WEBPAGE IS DEPRECATED - please visit our new website

Cache Chooser Add-On

  • creates cache from Topics and decides, if a Topic needs to be rerendered. TWiki users can have an influence on the caching time. CacheChooserAddOn takes account to TWikis content security.

Usage

  • After installation invisible for TWiki users.
  • Users may need to use a refresh button to rerender a Topic with content genereated by variables.
  • Users may set the NOCACHE variable to refuse caching of topics with no static content.
  • User can set the timeout of a page to be automatically be rerendered after time T.

How does it work

  • The chooser decides by the following facts, when to render a Topic to cache:
    • date of original Topic file is newer than file in cache
    • in Topic DENYTOPICVIEW or ALLOWTOPICVIEW are empty
    • in WebPreferences of a web, DENYWEBVIEW and ALLOWWEBVIEW are empty.
    • the NOCACHE variable is NOT set, neither in the Topic nor in WebPreferences
    • the CACHE variable is set with a value.
    • No QUERY_STRING options are specified, excepting ?skin=plain

Advantages - Disadvantages - When better not using caching

  • Caching is ideal for static content
  • In all other Topics and Webs which contain content that is generated by variables from actual TWiki content and require to be most actuell, caching shoud be disabled by setting the NOCACHE variable or at least set a short refresh-time with the CACHE variable.
  • Caching cannot and is not supported when User Authentication is used by restricting viewing Topics or Webs.
  • Caching is not supported, when QUERY_STRING options are specified to avoid conficts.

Speed Advantages

Time Experiment
40 ms cached Topic with no CACHE or NOCACHE variables in
76 ms cached Topic with CACHE or NOCACHE variables in
3358 ms rerended Topic with cache chooser
3276 ms directly rendered Topic without cache chooser
82 ms overhead through cache chooser programm

The measurement was done on a 700 MHz PC. In fact the little overhead of about 80 ms when rendering via the cache chooser does really not take much into account of the over 3 seconds rendering time, while the speed of Topics from cache is relatively really fast, especially for Topics which need not processed for variables again.

Stop Caching of a Topic or Web

  • For a Topic:
    • include the exact string: Set NOCACHE somewhere in the document.
    • You may hide it by <!-- Set NOCACHE -->
  • For a entire Web:
    • include the exact string: Set NOCACHE in the WebPreferences of that web.

Forcing Caching of a Topic in a Non-Cached Web

  • Include in the Topic:
    • Set CACHE = cache
That overwrites the NOCACHE variable in the Web, but will not overwrite User Authentication.

Cache Timeout of Topics

  • To define in WebPrefrerences in each Web
  • To define in each Topic
  • Order is: Topic beats Web

If the CACHE variable has a time information included instead of the word cache, it will rerender the Topic after timeout is reached. The format includes one string after the equal sign that has to be separated by one space on each sides! The format includes m=minutes, h=hours, d=days, w=weeks and M=months. Several time settings can be set together and are separated by " - " to build up one string! The letters follow directly after the number of time. Examples:

  • Set CACHE = 1d
  • Set CACHE = 5d-2w
  • Set CACHE = 1h-30m
  • Set CACHE = 1M-2w-5d-6h-3m

There are limitations in specifiable numbers:

  • m = 1-59
  • h = 1-29
  • d = 1-6
  • w = 1-9
  • M = 1-19

Especially for the CalendarPlugin the option daily will cause the Topic rerendered for the actual day to display the calendar properly, so set:

  • Set CACHE = daily

User Authentication

  • Due to security reasons, caching is disabled, when User Authentication is used in a Web or Topic.
  • When in a Topic Set ALLOWTOPICVIEW = Main. ... or Set DENYTOPICVIEW = Main. ... is set or
  • when in the the WebPreferences of a web Set ALLOWWEBVIEW = Main. ... or Set DENYWEBVIEW = Main. ... is set, followed by a user or group, caching is disabled. If activated later, the copy in the cache will be removed.
  • Attention! TIP: Be aware to keep the exact syntax as above! There has to be exact one space before and after the equal sign, otherwise Security may fail!
    • Wrong would be Set ALLOWTOPICVIEW =Main.TWikiGuest
    • Correct is: Set ALLOWTOPICVIEW = TWikiGuest

Add-On Installation Instructions

Note: You do not need to install anything on the browser to use this add-on. The following instructions are for the administrator who installs the add-on on the server where TWiki is running.

  • Download CacheChooserAddOn.zip ZIP file from TWiki:Plugins.CacheChooserAddOn
  • Unzip CacheChooserAddOn.zip in your twiki installation directory. Content:
    File: Description: down
    bin/cache Add-on script
    data/TWiki/CacheChooserAddOn.txt Add-on topic
    data/TWiki/CacheChooserAddOn.txt,v Add-on topic repository
    bin/view link to cache
    bin/refresh link to cache
    cache/.htcacherr.log log file of wrong CACHE variable entries
    bin/render original view script
  • Installationsteps:
    • copy cache to TWiki bin/
    • mv view to render
    • ln -s cache view
    • ln -s cache refresh
    • mkdir cache in TWiki directory, if web-server has no writing permissions there.
    • Add in your TWiki-skin a refresh button, e.g.:
    • Change /your/twiki/template/view.tmpl to have a refresh function, e.g. next to the the "More" link:
      %TMPL:P{"sep"}% <a href="%SCRIPTURLPATH%/refresh%SCRIPTSUFFIX%/%WEB%/%TOPIC%">Refresh</a>
    • Update TIP: 302 Moved messages cause wrong Localisation redirect, when view script is called with different name. Workaround is to use the ?refresh=cache option instead of the link refresh for the refresh button, e.g.: %TMPL:P{"sep"}% <a href="%SCRIPTURLPATH%/view%SCRIPTSUFFIX%/%WEB%/%TOPIC%?refresh=cache">Refresh</a>

  • Test if the installation was successful:
    • open Topics in your TWiki web and check, if directory tree and Topic-cache pages are created in the cache directory.
  • Protect cache dir in httpd.conf or with .htaccess by deny from all

Add-On Info

Add-on Author: TWiki:Main/JensRoeder
Add-on Version: 30 Mar 2005 (v1.000)
Change History:  
30 Mar 2005: Initial version
CPAN Dependencies: none
Other Dependencies: none
Perl Version: 5.005
License: GPL
Add-on Home: http://TWiki.org/cgi-bin/view/Plugins/CacheChooserAddOn
Feedback: http://TWiki.org/cgi-bin/view/Plugins/CacheChooserAddOnDev
Appraisal: http://TWiki.org/cgi-bin/view/Plugins/CacheChooserAddOnAppraisal

Related Topic: TWikiAddOns?

-- TWiki:Main/JensRoeder - 30 Mar 2005


Edit | Attach | Refresh | Diffs | More | Revision r1.1 - 26 Oct 2005 - 15:19 - Main.wwwrun