Speed up large sites by removing use of WEBLIST macro

  • Tip Category - Installation and Upgrading
  • Tip Added By - PaulHarvey - 01 Oct 2010 - 01:28
  • Extensions Used -
  • Useful To - Beginners
  • Tip Status - Under Review
  • Related Topics -

Problem

WEBLIST can contribute significantly to page rendering time on sites with a moderate number of webs ( > ~15), especially on virtual machines with slow disk i/o.

Context

A performance improvement is desired.

To measure the potential gain that you might obtain from removing use of the WEBLIST macro, compare timing results as a non-admin user:

The tests should be done with a non-admin (or as wikiguest) user account so that access-control overheads are included in the comparison.

Solution

Replace WEBLIST usage (Eg. from WebLeftBarExample) with an INCLUDE of a topic holding a static version of the WEBLIST output; or alternatively, over-write the WebLeftBarWebsList topic with the static output.

This topic will need to be re-generated each time a new web is added. Example:

<form action="%SCRIPTURLPATH{"save"}%/%SYSTEMWEB%/WebLeftBarWebsList" method="post">
<input type="submit" value="Re-generate"/>
<input type="hidden" name="redirectto" value="%BASEWEB%.%BASETOPIC%"/>
<textarea name="text">
   * *%MAKETEXT{"Webs"}%*
%WEBLIST{
  "   * <span style=\"white-space:nowrap\">
           <a href=\"%SCRIPTURLPATH{"view"}%/$name/%HOMETOPIC%\">
             <img src=\"%ICONURL{web-bg}%\" border=\"0\" alt=\"\" width=\"16\" height=\"16\" style=\"background-color:%$markerVAR{
               \"WEBBGCOLOR\" web=$qname
             }$marker%\" />&nbsp;<nop>$indentedname
           </a>
         </span>"
}%</textarea></form>

Known Uses

ALERT! This code hasn't been properly tested (a variation of it is in use at http://trin.org.au). Please update this topic if you find the example required changes to work.

Known Limitations

ALERT! Overwriting system topics is considered bad practice. The example is shown here for clarity. You are invited to re-write this topic with proper WebLeftBar customisation advice.

See Also

PerformanceSupplement

-- PaulHarvey - 01 Oct 2010

In addition to splitting out the web listing to a "static" System.WebLeftBarWebList, I wanted to make the text become bold for the site name on which the side bar was displaying.

<form action="%SCRIPTURLPATH{"save"}%/%SYSTEMWEB%/WebLeftBarWebsList" method="post"> <input type="submit" value="Re-generate"/> <input type="hidden" name="redirectto" value="%BASEWEB%.%BASETOPIC%"/> <textarea name="text"><br />
   * *%MAKETEXT{"Webs"}%*
%WEBLIST{ 
  "   * <span style=\"white-space:nowrap\" class='TMLhtml' > 
           <a href=\"%SCRIPTURLPATH{"view"}%/$name/%HOMETOPIC%\"  > 
             <img src=\"%ICONURL{web-bg}%\" border=\"0\" alt=\"\" width=\"16\" height=\"16\" style=\"background-color:%$markerVAR{ 
               \"WEBBGCOLOR\" web=$qname 
             }$marker%\" /> %IF<nop>{\"'%<nop>BASEWEB%' = '$indentedname'\" then=\"<b>$indentedname </b>\" else=\"$indentedname\"<nop>}<nop>%
           </a> 
         </span>" 
}%</textarea></form>

Example:

-- BobCorless - 24 Oct 2010

Good idea. I think we should invest in a little bit of jquery to bold or otherwise style the currently viewed web. foswiki.getPreference('WEB'); can get the web of the currently viewed topic. If for example this was 'FooWeb', and each <li> element was usefully id'd somehow, eg. <li id="foswikiWeblistWebFooWeb">, some jquery could add a foswikiWeblistCurrentWeb class to it (and leave it up to CSS to style appropriately)

This means less macro/CPU overhead on the foswiki server

-- PaulHarvey - 24 Oct 2010

BestPracticeTipsForm edit

Category Installation and Upgrading
Related Topics
Topic revision: r5 - 16 Sep 2011, PaulHarvey
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy