Apache Cache Control using mod_expires with Expires By Type

/ Published in: Apache
Save to your folder(s)

Use Apache's mod_expires to explicitly set the expiration of a file by it's type. This will enable to browser to cache these static assets and greatly increase performance.

Copy this code and paste it in your HTML
  1. <IfModule mod_expires.c>
  2. ExpiresActive on
  3. ExpiresDefault "now"
  4. ExpiresByType text/html "now"
  5. ExpiresByType text/xml "now"
  6. ExpiresByType text/css "access plus 8 hours"
  7. ExpiresByType text/plain "access plus 8 hours"
  8. ExpiresByType application/x-javascript "access plus 8 hours"
  9. ExpiresByType application/x-shockwave-flash "access plus 8 hours"
  10. ExpiresByType application/pdf "access plus 8 hours"
  11. ExpiresByType image/gif "access plus 8 hours"
  12. ExpiresByType image/png "access plus 8 hours"
  13. ExpiresByType image/jpeg "access plus 8 hours"
  14. ExpiresByType image/x-icon "access plus 8 hours"
  15. ExpiresByType video/x-flv "access plus 8 hours"
  16. ExpiresByType video/quicktime "access plus 8 hours"
  17. </IfModule>

URL: http://www.bytechemist.com/2008/06/27/apache-cache-control-using-mod_expires-with-expires-by-type/

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.