You could do this: Work with mod_rewrite to change requests from
/some/static/page.html
to
/htmlinjector.php?url=/some/static/page.html
then use PHP (or whatever you find appropriate) to do the file-manipulation. Add an output cache to improve performance.
As an alternative, Apache Handlers sound helpful:
Modifying static content using a CGI
script
The following directives will cause
requests for files with the html
extension to trigger the launch of the
footer.pl CGI script.
Action add-footer /cgi-bin/footer.pl
AddHandler add-footer .html
Then the CGI script is responsible for
sending the originally requested
document (pointed to by the
PATH_TRANSLATED environment variable)
and making whatever modifications or
additions are desired.
This is more or less what the mod_rewrite approach would do, only with less hackery.