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

TWiki Guest Cache Add-On

Speed up a TWiki site by caching topics for non-authenticated users

Overview

Public TWiki sites are frequently visited by search engine spiders and non-authenticated users. The actual traffic by authenticated users who browse and change content is typically less than 5% of all traffic. This add-on is designed to cache topics for non-authenticated users. Content is not cached for authenticated users - this ensures that personalized content remains personalized.

A typical TWiki page may load in about 1 second. A cached topic loads about 10 times faster.

Deploying this add-on on a public TWiki site tends to speed up the site for all users. It also reduces the CPU load considerably on a high traffic site. On TWiki.org the average CPU load dropped from 2-3 down to 0.2-0.5 after deploying this add-on.

Cache Algorithm

Once the add-on is installed and configured it can be forgotten, the caching and cache update is done automatically.

A topic is only cached if:

  • the user is not authenticated,
  • the requested URL has no parameters,
  • the requested topic exists,
  • the topic is not on the exclusion list.

The cached content is returned if all conditions are met and if the cache exists. If needed, a topic is cached or re-cached first.

A configurable cache invalidation determines when a topic is re-cached. There are three tiers:

  • Tier 1 topics, such as WebChanges, WebRss: Cache invalidation is 1 hour by default.
  • Tier 2 topics, such as WebHome, WebTopicList: Cache invalidation is 6 hours by default.
  • Other topics: Cache invalidation is 48 hours by default.

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

  • For an automated installation, run the configure script and follow "Find More Extensions" in the in the Extensions section.

  • Or, follow these manual installation steps:
    • Download the ZIP file from the Plugins home (see below).
    • Unzip TWikiGuestCacheAddOn.zip in your twiki installation directory. Content:
      File: Description:
      data/TWiki/TWikiGuestCacheAddOn.txt Add-on topic
      bin/viewcache View script with cache logic
      lib/TWiki/Contrib/TWikiGuestCacheAddOn.pm Add-on Perl module
      lib/TWiki/Contrib/TWikiGuestCacheAddOn/Config.spec Spec file for configure
    • Set the ownership of the extracted directories and files to the webserver user.
  • Add-on configuration and testing:
    • Configure the TWikiGuestCacheAddOn settings in the Extensions section.
      • Settings:
        # Comma-space delimited list of topic names to exclude:
        $TWiki::cfg{TWikiGuestCacheAddOn}{ExcludeTopics} = 'TWikiRegistration';
        # Comma-space delimited list of tier 1 topic names:
        $TWiki::cfg{TWikiGuestCacheAddOn}{Tier1Topics} = 'WebAtom, WebChanges, WebRss';
        # Maximum cache age for tier 1 pages, in hours:
        $TWiki::cfg{TWikiGuestCacheAddOn}{Tier1CacheAge} = '1';
        # Comma-space delimited list of tier 2 topic names:
        $TWiki::cfg{TWikiGuestCacheAddOn}{Tier2Topics} = 'WebHome, WebTopicList';
        # Maximum cache age for tier 2 pages, in hours:
        $TWiki::cfg{TWikiGuestCacheAddOn}{Tier2CacheAge} = '6';
        # Maximum cache age for default pages, in hours:
        $TWiki::cfg{TWikiGuestCacheAddOn}{CacheAge} = '48';
        # Debug flag:
        $TWiki::cfg{TWikiGuestCacheAddOn}{Debug} = 0;
    • Copy the twiki/bin/viewcache script to twiki/bin/view (overwrite the latter).
    • Test if the installation was successful:
      • Logout and view a topic as a not authenticated user.
      • On the shell, check if the cache file twiki/pub/.cache/<web>/<topic>.html has been created.
      • The second time you view a topic, it should load much faster.
      • Look at the tail of the TWiki log file twiki/data/log201610.txt to verify that cached content is returned you should see "from cache" entries. Example:
        | 2016-10-15 - 01:29 | guest | view | Support.SupportForum | Mozilla - from cache | 1.2.3.4 |

Add-On Info

  • Set SHORTDESCRIPTION = Speed up a TWiki site by caching topics for non-authenticated users

Add-on Author: TWiki:Main.PeterThoeny
Copyright: © 2009-2015 TWiki:Main.PeterThoeny
© 2009-2015 TWiki:TWiki.TWikiContributor
License: GPL (GNU General Public License)
Add-on Version: 2015-10-09
Change History:
2015-10-09: TWikibug:Item7568: Typo fixes -- thanks TWiki:Main.RobertBagwill
2015-04-28: TWikibug:Item7627: Use engine->run() to initiate TWiki
2015-03-20: TWikibug:Item7627: Add configuration option to exclude topics from caching
2013-10-25: TWikibug:Item7371: Add BlogFeed to list of rss content-type pages
2013-10-17: TWikibug:Item7371: Align date format with TWiki-6.0, e.g. add seconds to log entries
2013-07-01: TWikibug:Item7154: Clean up anchor links of TOC so that no login is required when a guest clicks on a TOC link
2013-02-22: TWikibug:Item7154: Check for failed cache with zero byte content, if so, return regular TWiki page
2013-02-22: TWikibug:Item7154: Output proper content type for RSS & ATOM feeds
2012-12-28: TWikibug:Item7112: Call view script from command line, no need for wget to cache topics
2012-12-22: TWikibug:Item7094: Initial version
TWiki Dependency: $TWiki::Plugins::VERSION 1.3 (TWiki-5.0)
CPAN Dependencies: none
Other Dependencies: none
Perl Version: 5.005
Add-on Home: http://TWiki.org/cgi-bin/view/Plugins/TWikiGuestCacheAddOn
Feedback: http://TWiki.org/cgi-bin/view/Plugins/TWikiGuestCacheAddOnDev
Appraisal: http://TWiki.org/cgi-bin/view/Plugins/TWikiGuestCacheAddOnAppraisal

Related Topic: TWikiAddOns

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatmd5 TWikiGuestCacheAddOn.md5 r13 r12 r11 r10 r9 manage 0.2 K 2015-10-09 - 22:28 PeterThoeny  
Compressed Zip archivetgz TWikiGuestCacheAddOn.tgz r13 r12 r11 r10 r9 manage 7.5 K 2015-10-09 - 22:28 PeterThoeny  
Compressed Zip archivezip TWikiGuestCacheAddOn.zip r13 r12 r11 r10 r9 manage 9.9 K 2015-10-09 - 22:28 PeterThoeny  
Unknown file formatEXT TWikiGuestCacheAddOn_installer r2 r1 manage 3.5 K 2015-10-09 - 22:28 PeterThoeny  
Edit | Attach | Watch | Print version | History: r12 < r11 < r10 < r9 < r8 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r12 - 2015-10-09 - 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-2016 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.