Tags:
caching2Add my vote for this tag performance1Add my vote for this tag create new tag
, view all tags

TWiki Cache Add-On

This add-on allows you to cache pages in TWiki and, with smart algorithm :-)), almost always gives you the latest version of page.

Well, because our TWiki grows very fast and the response from our server was slower and slower, we need some cache mechanism to relieve the server. I tried to use CacheAddOn but it doesn't work as I need. The biggest problem was that we use authentication for all operations in TWiki and we use modified version of KoalaSkin, where users can modify many things by their needs. It means that caching pages for all users in one place wasn't possible because the rendered HTML page was different for every user.

That's why I created my own caching mechanism. The caching algorithm works in this way. It starts view script and search cache directory. If it finds a cached HTML page then the algorithm checks these conditions:

  • is cached page newer than topic
  • is cached page newer than included topics
  • contains topic %SEARCH% or %ACTIONSEARCH% (depends on CACHESEARCH variable)
  • is cached page newer than generated templates (if KoalaSkin is enabled)

If these conditions are fulfilled then the cached page is returned else the page is rendered as normal and is cached for later use. The next problem I found with CacheAddOn was when I try to see topic in some revision, sort tables, use SlideShowPlugin etc. In my version it works OK. It means that you should in every case get the latest version of the page.

The algorithm doesn't check any changes in user preferences that affect rendering of TWiki pages. There are two possibilities to solve this problem:

  • use refreshing
  • clean the cache and start caching from scratch

In our TWiki I add to the view template 'Refresh' button that points to the same topic with parametr 'nocache=on' (for example for actual topic it is: http://twiki.org/cgi-bin/view/Plugins/TWikiCacheAddOn?nocache=on).

Then I add to the oopsmore template the possibility to clean the cache (add link to: http://twiki.org/cgi-bin/cache). If you use per user cache then each user can clean only his/her cache.

Usage

Administrator setting

You have to set up these variables in TWiki.cfg file in lib directory:

$cacheDir directory where the generated HTML files will be stored
$useCache this allows to use caching in TWiki (default: "0")
$usePerUserCache this enables per user caching. If you have restricted access to view script and users use different skins you have to set this variable to "1" because the generated page is different for every user. (default: "0")
$cacheGroup set group name which should be owner of created files (default: "")
$cacheFileRights set UNIX rights for created files (default: 0777)
$cacheDirRights set UNIX rights for created directories (default: 0777)

!!! YOU HAVE TO SET UP AT LEAST $cacheDir VARIABLE !!! The others are set to default values if not set.

Note: When you set useCache variable to "1" it doesn't mean that caching is enabled (it only allows to administrator disallow caching if he needs). If you want to cache pages of all users you have to set USECACHE variable to "on" in TWikiPreferences topic. Else each user can specify in his user-topic if he wants to use caching or not (USECACHE = on/off).

User setting

You can use these variables to set caching by your needs:

USECACHE on/off this allows you to cache TWiki pages (default: off)
CACHESEARCH on/off this allows to cache pages with SEARCH (default: off)

Note: Now it checks %SEARCH% and %ACTIONSEARCH% variables as topics with search. If you use any other search variables you need to modify the view script.

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 the ZIP file from the Add-on Home (see below)
  • Unzip TWikiCacheAddOn.zip in your twiki installation directory. Content:
    File: Description:
    bin/view 'view' script with caching possibility
    bin/cache 'cache' script for cleaning the cache if needed

Note: Of course, don't forget to backup your current view script in case my script will not work!!!

Add-On Info

  • Set SHORTDESCRIPTION = Cache pages in TWiki for better performance

Add-on Author: RichardBaar
Add-on Version: 27 Aug 2003 (v1.000)
Change History:  
27 Aug 2003: Initial version
CPAN Dependencies: none
Other Dependencies: none
Perl Version: 5.005
License: GPL
Add-on Home: http://TWiki.org/cgi-bin/view/Plugins/TWikiCacheAddOn
Feedback: http://TWiki.org/cgi-bin/view/Plugins/TWikiCacheAddOnDev

Related Topic: TWikiAddOns

This work was sponsored by Systinet Corp.

-- RichardBaar - 27 Aug 2003

Topic attachments
I Attachment History Action Size Date Who Comment
Compressed Zip archivezip TWikiCacheAddOn.zip r1 manage 6.3 K 2003-08-27 - 11:18 RichardBaar Version 1.0
Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2006-11-04 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.