Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache file caching

How does apache handle caching of certain files, and is it possible to explicitly say that certain files should be aggressively cached more than others, through the standard config files for a given host or virtualhost?

To put it in context, I keep a lot of site content in various XML files, and I'd like to be able to say that this file will be used a lot, and therefore cache it as much as possible..? Does apache do this kind of thing intelligently and on the fly..? Will it observe which files are more popular than others and try to match cache hits appropriately..?

Lots of questions in one, but the basic idea should be clear enough.

edit: to be clear, these are resource files which are loaded and interpreted by PHP - but php as a process is spawned inside apache.. right? Please help!

like image 793
dmp Avatar asked Feb 28 '23 19:02

dmp


2 Answers

  1. Apache is just a web-server. It doesn't know specific of your application, so it is responsibility of your application to cache results.
  2. You can use application unaware module in apache - mod_cache. Also, see example of configuration in article Caching Dynamic Content with Apache httpd. This module allows you to specify what should be cached and what shouldn't be cached.
  3. Also, you can use some PHP-specific caching mechanism, e.g. Alternative PHP Cache or memcached.
like image 58
uthark Avatar answered Mar 04 '23 18:03

uthark


If you are serving the XML files directly from Apache, with no intervening CGI scripts or language module such as PHP, then you should look at mod_file_cache. From your description, I think it's what you're looking for.

like image 24
zombat Avatar answered Mar 04 '23 18:03

zombat