[pmwiki-users] HtmlCache, Internationalizazion, layout problem

Patrick R. Michaud pmichaud at pobox.com
Wed Jul 19 09:40:55 CDT 2006


On Wed, Jul 19, 2006 at 04:13:21PM +0200, Thomas Bley wrote:
> Thanks have tried it.
> The light skin has some calls to SetTmplDisplay which is calling 
> NoCache. These calls are even made if there is not authentication.

Hmm, I don't remember why I configured SetTmplDisplay to call
NoCache(), but I think I can eliminate it there.

> The (un)serialize used in handlebrowse has no use (maybe had some in the 
> past ?), but costs a lot of performance.

The serialize is so that eventually we can store additional information
in the ,cache file besides just the HTML text -- i.e., we could potentially
store a list of pages the cached page depends on, or any additional
headers that need to be sent along with the page.  At any rate, the
performance cost of (un)serialize is negligible relative to the cost
of re-rendering the entire page.

> Also there are some calls like SetProperty($pagename, 'description', 
> PSS('$1'), ' ')) done from MarkupToHTML(), SetProperty calls NoCache, 
> this disables htmlCaching.

SetProperty currently has to do a NoCache() because otherwise
the <title>, <meta content='keywords' ... />, and 
<meta content='description' ... /> header tags won't be rendered
in the <head> section of the document.

> Looking at the cache files only the content of the pagename is getting 
> cached, not the sidebar / header / footer.

Yes, because the sidebar, header, and footer frequently change based
on visitor authentication (e.g., Site.PageActions is a good example), 
and because the HTTP headers may change depending on the page contents.

In addition, many sites have the Cookbook.SkinChange recipe enabled,
thus caching the entire page saves the wrong sidebar/header/footer
if a browser has chosen a different skin (via ?setskin=...).

So, for the great majority of PmWiki sites, caching the page without
its sidebar/header/footer is far superior and more flexible than
caching the entire page.

> Here is my HandleBrowse() enabling caching and compressing of the whole 
> page:
> It's only cached for 1 hour to get modifications of the sidebar / header 
> / footer, maybe there is a better way ?

It's often easier to simply compare against the $LastModTime
variable (which contains the time that *any* page or configuration file
on the site has been modified).  This avoids regenerating the page each
hour for no reason.

> ## handle display of a page
> [...]
>  if (@$EnableHTMLCache && !$NoHTMLCache && $PageCacheFile && 
> @filemtime($PageCacheFile) > $LastModTime && 
> @filemtime($PageCacheFile)+3600 > time()) {
>    $IsHTMLCached = 1;
>    if (strpos("@".@$_SERVER["HTTP_ACCEPT_ENCODING"],"gzip") && 
> file_exists($PageCacheFile.",gz")) {
>      header("Content-Encoding: gzip");
>      echo file_get_contents($PageCacheFile.",gz");
>    } else {
>      echo file_get_contents($PageCacheFile);
>    }
>    exit;

Note that this doesn't properly set any HTTP headers; for example, 
it won't work for languages or character sets other than PmWiki's 
default (English, ISO-8859-1), and it won't provide a valid
Last-Modified header to the browser.

Pm




More information about the pmwiki-users mailing list