On Wed, 12 Sep 2001, Joshua Chamas wrote:
> $Response->Include({
> File => 'file.inc',
> Cache => 3600, # to cache one hour
> Key => [\%data || \@data || \$data || $data || undef]
> },
> @args
> );
Why is there a time limit on how long something can be cached? Wouldn't
someone usually want the page to be cached indefinitely (space
permitting)? I guess if someone doesn't specify a time limit, it should be
infinite.
I'm guessing there should be a directive that allows someone to set the
maximum number of bytes that the cache is allowed to take (e.g. PerlSetVar
MaxCacheSize), and some LRU/LFU policy could be employed when the cache
fills up.
> But if it doesn't have to be created, then I won't create it.
> Does it seem sensible to auto purge your cache every server
> restart?
Let's see...we have three kinds of server restarts:
1. apachectl graceful
2. apachectl restart
3. apachectl stop; apachectl start
It would make sense to clear the cache when #3 happens, since that's a
cold restart and everything else is cleared.
I'm guessing you were asking about case #2. IIRC, when someone does
"apachectl restart", all the modules are recompiled, so I think you'd HAVE
to clear the cache too, otherwise weird things can happen.
As for case #1, it might be useful to be able to clear the cache without
shutting down the server completely, although I'm not saying that *I* need
that functionality.
Another thought: What if I want the entire contents of a script to be
cached? e.g. I want "page.asp" to be cached based on its query string.
Would I have to put this:
<% $Response.Include({
File => 'real_page.inc',
Key => $Request->QueryString
}); %>
and then put the entire real page in real_page.inc? That seems a bit
cumbersome to have to create a whole file just for one cache directive,
but I don't have an alternative suggestion at the moment.
Another thought: How would we do conditional cache refreshing? e.g. let's
say I have a script "view.asp?id=5". The results of this script should be
cached, BUT if the entry in the database for 5 has changed, it should not
be pulled from the cache. How about something like this, then:
<%
my $id = $Request->QueryString('id');
my $time = $dbh->selectrow_array("SELECT modified FROM
data WHERE id=".$dbh->quote($id);
$Response->Include({
file => 'view.inc',
key => $id,
timestamp => $time
});
So, if the cache has an entry for "view.inc?id=5", it will compare the
time of the cache file with $args{timestamp} to determine whether it needs
to invalidate that cache entry. "modified" would be a TIMESTAMP column in
MySQL, which automatically gets touched if that row is updated. There
could also be an "invalidate" parameter, which if true, will tell
$Response->Include not to pull the page from the cache under any
circumstances. It's probably useless if we have "timestamp" available,
though.
In summary, my suggestions are:
1. Add a MaxCacheSize config parameter to allocate disk space for the cache
2. Clear cache on "restart"; maybe make config parameter to allow clearing
cache on "graceful"
3. Is it a bit cumbersome to need to create an entire file just as a cache
directive? Can we do better?
4. Perhaps add a "timestamp" and/or "invalidate" parameter to
$Response->Include to allow more powerful cache control
Ack, did I create more questions than I answered? :)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]