Re: Content management and caching

From: Manuel Lemos (mlemos_at_acm.org)
Date: 10/14/04


Date: Thu, 14 Oct 2004 14:56:05 -0300

Hello,

On 10/14/2004 02:20 PM, Markus Ernst wrote:
> I use PEAR Cache to cache the frontend pages of a content managed web site.
> Now I update the contents of a page, and of course the updated contents will
> only be displayed after the expiring period of the cached file.
>
> After thinking and googling a lot I see several possible approaches to for
> handling this, each of which has it's downsides:
>
> - Use a very short expiring period. (Downside: Makes caching only relevant
> at very high visitor frequencies.)
>
> - Change database, add modification date to every record - and compare
> creation date of cache files with modification dates of contents. (Huge
> overhead; must first detect which tables and records the page uses at all.)
>
> - Flush cache everytime an admin page is called, or within the insert,
> update, publish etc functions. (Empties whole cache also if only a comma is
> changed.)
>
> - Provide an "flush cache" button for the administrator to use after
> finishing changes. (Administrator will forget it.)
>
> I would appreciate any better ideas or comments, thank you.

You may want to try this other generic cache class that stores arbitrary
cache data in files. It comes with a function that lets you invalidate a
specific cache file forcing the content to be regenerated next time the
cache is used.

I use this precisely for the same reasons as your in a site where over
10.000 content blocks are cache in files taking over 150MB . Some of the
cache files expire after a certain amount of time but in some cases I
need to force certain cache files to be regenerated due to some event
that could not be antecipated when it would happen.

This solution works wonders not only for that purpose but also because
it uses safe locking which is very important to prevent cache corruption
in a busy site like I have when many simultaneous user accesses attempt
to verify and update the same cache files.

http://www.phpclasses.org/filecache

-- 
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html