Apache web server tips and tricks
There are may small and big features in Apache that make it one of the easiest web server to configure and administrate.In this post I am posting some of the tips and tricks that I found incredibly useful.
Finding request serving time as an extra header in Apache 2.4
This one is especially useful if you have server side dynamic content(like PHP pages or reverse proxy calls) and want to find out the exact time taken by apache since the request came in and the request was sent out by apache
LoadModule headers_module modules/mod_headers.so Header set Request-Serving-Time "It took %D microseconds for Apache to serve this request.
Using Disk Cache in place of Memory Cache for static content.
Contrary to what one may think, memory cache in Apache is slower than disk caching, because mod_mem_cache uses the read API to load the file into memory where as mod_disk_cache uses sendfile API to directly send file to endpoint, which doesn’t require the file to be read bit by bit and its also cached in the operating system’s file system cache.
Here is a snippet to enable mod_disk_chche in Apache.
LoadModule disk_cache_module modules/mod_disk_cache.so <IfModule mod_disk_cache.c> # "/s" is where Confluence serves "static" stuff. Instruct Apache to cache it: CacheEnable disk /s CacheIgnoreHeaders Set-Cookie CacheRoot "/var/cache/mod_proxy" </IfModule>
Sadly mod_mem_cache doesn’t provide an upper bound on how much memory it will use to make sure that you manually free the space. This can be done using the following command in linux.
sudo htcacheclean -d30 -n -t -p /var/cache/mod_proxy -l 512M
Leave a Reply