Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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...

share|improve this question
If you're at a scale where you need this kind of caching why not consider a CDN for your static resources? –  voretaq7 Sep 4 '13 at 17:09

1 Answer 1

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.

share|improve this answer
I'd like to vote up but not enouth rep points. U didnt answer my question but helped me. So thanks :D –  tamere22 Sep 5 '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 5 '13 at 16:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.