Code Snippets and More

To enable items cache in the client side only, you only need to have installed on your Apache server the mod_expires module. Once installed, specify a default cache for all elements accessed by our server is as easy as typing the following directive in the httpd configuration of our site (.htaccess or httpd.conf):

ExpiresActive On
ExpiresDefault "access plus 1 month"

* One month expiration since the access for all elements.

Probably, a better directive for heavy web elements like images, CSS's and JS's based on the filetype:

ExpiresActive On
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 24 hours"
ExpiresByType text/javascript "access plus 24 hours"

Recent comments

© 2014 Copyright by Keyvan Akbary