> I would like to propose a new Apache module before I send it off to
> CPAN.  The name chosen is Apache::CacheContent.

This is very cool.  I was planning to write one of these, and now I don't
have to.  Your implementation is short and interesting.  I was planning to
do it with a PerlFixupHandler and an Apache::Filter module to capture the
output.  While that approach wouldn't require the use of method handlers, I
think yours may be easier for newbies because it doesn't require them to
understand as many modules.  The only real advantage of using Apache::Filter
is that it would work well with existing Registry scripts.

A couple of other C's for your R:

A cache defines parameters that constitute a unique request.  Your cache
currently only handles the filename from the request as a parameter.  It
would be nice to also handle query args, POST data, and arbitrary headers
like cookies or language choices.  You could even support an optional
request_keys method for handlers which would let people generate their own
unique key based on their analysis of the request.

Doing this would mean you would need to generate filenames based on the
unique keys (probably by hashing, as in Cache::FileCache) and do an internal
redirect to that file if available when someone sends a request that
matches.

Another thing that might be nice would be to store the TTL with the file
rather than making the handler give it to you again each time.  This is done
in mod_proxy by putting an Expires header in the file and reading it before
sending the file, but you could also store them in a dbm or something.
Support for sending Expires headers automatically would also be useful.

When I first thought about this problem, I wanted to do it the way Vignette
StoryServer does: by having people link to the cached files directly and
making the content generating code be the 404 handler for those files.  That
gives the best possible performance for cached files, since no
PerlFixupHandler needs to run.  The downside is that then you need an
external process to go through and clean up expired files.  It's also hard
to handle complex cache criteria like query args.  StoryServer does it by
having really crazy generated file names and processing all the links to
files on the way out so that they use the cached file names.  Pretty ugly.

I know you guys are pushing to get the book done, so don't feel pressured to
address this stuff now.  I think the current module looks more than good
enough for an initial CPAN release.

- Perrin

Reply via email to