1

I have a Java image resizing app which resides in a Tomcat container. I would like to use Apache as a frontend Reverse-Proxy to the Tomcat machine which also caches the image requests. I do not want to load hundreds of image requests over and over, as the browser has most probably already downloaded them in the cache.

The reverse proxy was easy to do. However, the caching did not work out as I intended it. I used mod_expires and set it to expire the jpeg requests in one month. As I started inspecting the request-response dialogs, I realized that the expires would catch and probably set the expiry of a jpeg file once it has been fetched from the app, not before. This means that the proxy will anyway request the entire file from the Tomcat machine, and will then eventually do some caching.

How do I set up caching based on a certain path fragment? let's say I have the following path structure:

/image/*image_UUID/*width_*height

I want to make so that the proxy prevents the generation of a new thumbnail (e.g. /image/1aaC45zksZGc/500_400 ) with one month

user1219569
  • 115
  • 5
  • Why not go for even faster servers? As nginx or lighthttpd? – i.am.michiel Mar 02 '12 at 10:30
  • @Zenklys how would that help? I want to minimize the data traffic in general. If the browser already has a cached version of the pic somewhere, why should the server bring it again as a response. I doubt that a faster server will help solve that. – user1219569 Mar 02 '12 at 12:56
  • Did you use mod_proxy with mod_ajp ? – rkosegi Mar 02 '12 at 14:24
  • What I am trying to say is that, you can very well define cache-rules using nginx or lighthttpd. The difference is that they will consume less memory and much better handle concurrency. – i.am.michiel Mar 02 '12 at 14:37

0 Answers0