Wednesday, August 17, 2011

Caching Configuration in Apache

The goad of caching in Apache could be
-Reduce Number of request in man cases
-Eliminate need to send full response in many cases

For former we use Expiration mechanism and for later we use validation mechanism.

For Apache mod_expires and mod_headers handles cache control through http headers.

mod_expires module control setting of expires and cache-control http header in server response.

For example to enable mod_expires for all .html files, we can use following syntax
ExpiresActive On
ExpiresDefault A300
Expires A86400

In Above example, default caching is for 5 minutes(A300) but for html files caching is 1Day(A86400).

Now suppose we want to disable caching for dynamic pages located in folder /var/www/phpfiles

Header Set Cache-Control "max-age=0,no-store"