3

I'm using an apache as frontend webserver that load balance users between 3 nodes of tomcat web servers. I use mod_jk to do that.

What I want is how can I configure apache on this presentation server so that it would cache all files with specific extensions (like .js, .png, .jpg) ? mod_cache ?

Thanks a lot.

edit: I can't change anythin on the tomcat web servers. So all the magic has to happen on the apache presentation load balancer server...

tamere22
  • 31
  • 1
  • 2
  • If you're at a scale where you need this kind of caching why not consider a CDN for your static resources? – voretaq7 Sep 04 '13 at 17:09
  • tamere22, did you figure a way to do this at all? Please share as I am looking for same solution. Will appreciate any info. –  Dec 10 '15 at 06:43

1 Answers1

5

mod_cache is indeed the usual solution here if you want the Apache server to cache content for you.

You can not, as far as I'm aware, cache by file type or extension in mod_cache -- the caching is controlled by URL and Header information (so if you want to cache all your images the easiest way to accomplish this is to serve them from an /images directory, tell mod_cache to cache stuff coming out of that directory, and let it do its magic).


mod_file_cache is an alternative you can consider if the list of stuff you want to cache is static (a specific list of JS, images, CSS, etc.) -- there are some additional caveats there, particularly if you use MMapFile to keep the files hot in memory, but the improved performance can be substantial over "traditional" caches like mod_cache.


More good information on Apache's caching capabilities can be found in the caching section of the Apache docs, but I think the two options above are your best bets. If you need something better than those a CDN is probably more your speed.

voretaq7
  • 79,345
  • 17
  • 128
  • 213
  • I'd like to vote up but not enouth rep points. U didnt answer my question but helped me. So thanks :D – tamere22 Sep 05 '13 at 16:08
  • @tamere22 If you find a way to specify file extension (or MIME types) for caching with `mod_cache` do post an answer and let us know -- it could be useful. – voretaq7 Sep 05 '13 at 16:23