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.
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:
- mod_file_cache documentation.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 0 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |