Tim Watts wrote:
Hi,
Is it in theory possible to insert a perl output filter between
mod_proxy and mod_cache?
Or at least between mod_proxy and the client?
The problem I'm trying to solve is this:
We have 100+ web servers where apache fronts a separate tomcat server
using mod_proxy.
Sadly, the tomcat dev's forgot to set any caching headers in the HTTP
response (either Expires, Last-Modified or Cache-control) so the sites
are largely uncacheable by browsers and the various tomcats are becoming
overloaded.
1/3 of our sites are typically invariant (the production sites have
stable and unchanging data and most queries are via GET requests).
Therefore, the idea of forcing in some cache control headers en-route
and also enabling some apache caching has a good chance of working well
without affecting anything.
mod_headers and mod_proxy don't seem to play well together and mod-cache
doesn't either (probably due to lack of cache control headers in the
tomcat response, though I haven't proved this is actually the case).
So the thought of doing a perl based filter to insert cache-control
headers occurred.
It is likely I can insert such a filter on Apache 2.2 *between*
mod_proxy and mod_cache?
Or am I going to have to implement a filter that includes proxying
and/or caching?
(That would probably be difficult, inefficient or both)
Assuming that what you say about Tomcat is true (I don't know, and it may be worth asking
this on the Tomcat list), I can think of another way to achieve what you seem to want :
if you can distinguish, from the request URL (or any other request property), the requests
that are for invariant things, then you could arrange to /not/ proxy these requests to
Tomcat, and serve them directly from Apache httpd.
Which proxying method exactly are you using between Apache and Tomcat ? (if you are using
mod_proxy, then you are either using mod_proxy_http or mod_proxy_ajp; you could also
consider using mod_jk).
Also, what are the versions of Apache and Tomcat that you are using ?