Caching in Apache

In Apache, there are three ways to set cache control rules:

1.Via <meta> tags (<meta http-equiv="Expires"...>)

This method works with browsers, but most intermediate proxy servers don’t parse HTML files, they look for HTTP headers to set caching policy.

2.Programmatically by setting HTTP headers (in PHP scripts etc.)

This method is useful for dynamic PHP scripts that output dynamic data. This is done by setting cache control headers (Expires and CacheControl for example).

3.Through web server configuration file (httpd.conf)

This approach is widely used for caching of static web objects. This requires mod_expires and mod_headers to be installed with apache. To turn on mod_expires set ExpiresActive to ON and target the web directory to specify the expiry time for all files based on their extensions. Eg:

<Directory "/home/website/public_html">    Options FollowSymLinks MultiViews    AllowOverride All    Order allow,deny    Allow from all    ExpiresDefault A300    <FilesMatch "\.html$">        Expires A86400    </Files>    <FilesMatch "\.(gif|jpg|png|js|css)$">

        Expires A2592000    </Files></Directory>

You may refer to the “Use Server Cache Control to Improve Performance” article for more details.

Bookmark this post: technorati Caching in Apache delicious Caching in Apache stumbleupon Caching in Apache digg Caching in Apache facebook Caching in Apache yahoo Caching in Apache google Caching in Apache magnolia Caching in Apache reddit Caching in Apache windowslive Caching in Apache

Tags: , ,

Related posts

0 Responses to “Caching in Apache”


  1. No Comments

Leave a Reply




/kapil/blog is Digg proof thanks to caching by WP Super Cache!