I'm making use of Apache 2.4.10 on Ubuntu 15.04 and my entire server runs on a SSD and is virtualised in Hyper-V.

  1. When should I enable mod cache in Apache 2.4?

Currently I have pretty good TTFB for static files. (0.015 - 0.020 seconds TTFB, when the ping is ~7ms)

  1. I doubt using a cache makes any sense here since I assume most of the TTFB is caused by setting up the TCP connection. -Is this assumption correct?

I've noticed that dynamic content e.g PHP scripts are having a much higher TTFB (e.g. 0.085-0.120 seconds).

  1. Would enabling caching in Apache make the loading of this dynamic content any faster?

I've read that I should use mod_disk_cache because it makes use of sendfile API in Linux which makes it faster than mod_mem_cache, others say the mem_cache is faster.


The first performance decision I made was to use –enable-disk-cache after doing some research I found that contrary to what you would think, disk cache is faster then memory cache when it comes to Apache mod_cache and OS interaction. The reason why is when you use mod_mem_cache the process of reading a file into memory, basically copying its data into RAM and thus kernel buffer in order to deliver it is not optimal. When using mod_disk_cache Linux uses the sendfile API, which does not require the server to read the file before delivering it. The server identifies the file to deliver and the destination via the API, the OS then reads and delivers the file, so no read API or memory for the payload is required, and the OS can just use the file system cache. So the kernel acts as a buffer, increasing cache speed.


Source: http://www.philchen.com/2009/02/09/some-tuning-tips-for-apache-mod_cache-mod_disk_cache

  1. So which is the best caching method memory or disk?

  2. Does it even make sense to use mod_disk_cache on the same drive as the web folder? I would assume it would just use a different directory to load the cached files, instead of reading the source files. But I don't see why this would be any faster..


Bro im having a issue similar but, but you have consider using fastcgi? im making test in that, and remember that u must use cache with some data in the app (system or whatever are u serving) im was thinking on mod cache, but i found your question! and i realize that with apc cache will work (im not so sure about using it)

That is for one, yeah the simple fact of opening or closing and conn with take time so therefore using fastgi that is a kinda a proxyserver will improve the time (using socks)

and for using mem or disk, since u have ssd hdd the response time will no improve a lot using mem or disk

there is plenty of material for seting up this mod on digital ocean

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.