For the landing page of my website, I am using an Ubuntu 14.10 LTS with Apache 2 hosted on a Digital Ocean instance. Initially I wanted to add a shortcut icon to the landing page and ended up screwing the LESS file. After reversing my commit and pushing the changes, I logically had to
git pull the changes. I did, but surprisingly, changes did not apply. I immediately cloned the repository on my local machine, fired up the local Apache and there it was: Working like a Charm.
So now I am REALLY confused. I Google Cache in Apache 2 and all results show that in case you do not use any of the cache modules like
mod_cache, it is not possible for Apache 2 to cache anything. The funny thing was when I cloned the repo as a sub-directory inside the folder, it also worked but once I was coming back, Apache was still serving the old CSS: I was insane!
Okay, so SOMETHING is telling Apache not to serve the new file, it's not caching but then what is it?!
According to Apache 2 Documentation:
This directive controls whether httpd may use the sendfile support from the kernel to transmit file contents to the client. By default, when the handling of a request requires no access to the data within a file -- for example, when delivering a static file -- Apache uses sendfile to deliver the file contents without ever reading the file if the OS supports it.
The more important part of the documentation is here:
With a network-mounted DocumentRoot (e.g., NFS or SMB), the kernel may be unable to serve the network file through its own cache.
Basically, when we perform a
git pull, our DocumentRoot becomes a network-mounted
DocumentRoot and by default, Apache serves the cached version of the file.
So the common belief that apache does not cache static content is a misbelief. It is crazy when you think about it, however the solution is rather straightforward.
If you wanna solve this for each virtual host, Just add the following lines inside you Virtual Host Configuration:
<Directory "/path-to-nfs-files"> EnableSendfile Off </Directory>
or if you want to disable this feature globally (that is what I actually did), add the following line at the end of your Apache 2 configuration file (by default it exists in