httpd Content Caching - saviovettoor/DevOps-wiki GitHub Wiki
httpd content caching
HTTPD Installation
]#wget http://archive.apache.org/dist/httpd/httpd-2.4.39.tar.gz
]#tar xfz httpd-2.4.39.tar.gz
]#cd httpd-2.4.39/modules/cache/
]#yum install gcc gcc-c++ kernel-devel
]#apxs -i -a -c mod_file_cache.c
]#apxs -i -a -c mod_mem_cache.c
Adding cache module
Add the below lines in httpd.conf
LoadModule cache_module modules/mod_cache.so
LoadModule file_cache_module /usr/lib64/httpd/modules/mod_file_cache.so
LoadModule expires_module modules/mod_expires.so
Add the below lines in the last place of httpd.conf
CacheEnable disk /
CacheRoot /var/cache/httpd/proxy
CacheDefaultExpire 360
CacheIgnoreNoLastMod On
CacheMaxFileSize 512000
Creating folder for cache and giving proper permission
]#mkdir -p /var/cache/httpd/
]#chown -R root:apache /var/cache/httpd/
]#chmod -R 775 /var/cache/httpd/
Configure httpd as a service
mkdir -p /etc/systemd/system/httpd.service.requires
ln -s /usr/lib/systemd/system/htcacheclean.service /etc/systemd/system/httpd.service.requires
EDIT: the below parameters in vi /etc/sysconfig/htcacheclean
# Configuration options for systemd service, htcacheclean.service.
# See htcacheclean(8) for more information on available options.
# Interval between cache clean runs, in minutes
INTERVAL=60
# Default cache root.
CACHE_ROOT=/var/cache/httpd/proxy
# Cache size limit in bytes (K=Kbytes, M=Mbytes)
LIMIT=100M
# Any other options...
OPTIONS=
Staring the httpd
systemctl restart httpd.service && systemctl start htcacheclean.service
Now access the URL and check if the directory "/var/cache/httpd/" is reflecting the cached contents.