About Linux FAQ

Browse More FAQs:

Apache Web Server Cache Frequently Used Files To Improve Performance

Posted by Vivek Gite [Last updated: June 30, 2008]

This FAQ is part 3 of 3 in the series Apache

Q. I'd like to cache few static pages or files that are viewed frequently such as index.html or order.html and so on. How do I cache files under Apache with using proxy solution?

A. You need to use mod_file_cache which can cache frequently requested files that change very infrequently is a technique for reducing server load. mod_file_cache provides two techniques for caching frequently requested static files. These techniques reduce server load when processing requests for these files by doing part of the work (specifically, the file I/O) for serving the file when the server is started rather than during each request.

WARNING! You cannot use this moule for speeding up CGI / php / perl / python dynamic programs. It can only be used for regular files which are usually served by the Apache core content handler.

How do I configure mod_file_cache?

Open your httpd.conf file, enter:
# vi httpd.conf
To cache index.html and faqs.html, enter:
MMapFile /var/www/domain.com/index.html
MMapFile /var/www/domain.com/faqs.html

How do I cache all static files in a directory called /kb/?

Try the following code to get listing of all files:
# find /var/www/domain.com/kb/ -type f -print | sed -e 's/.*/mmapfile &/' > /etc/httpd/conf.d/mmap.conf

Now open httpd.conf file, using the Include directive:
Include /etc/httpd/conf.d/mmap.conf
Save and close the file. Restart httpd:
# service httpd restart

References:

Navigation for Apache«Apache prevent hot linking or leeching of images using mod_rewrite howto

E-mail this to a friend      Printable version

Related Other Helpful FAQs:

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Tags: , , , , , , , ,

Copyright © 2006-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.