Apache Expires Headers with mod_expires

Quick example of how to set default expires headers. This will help prevent browsers from re-downloading the same images more than once and therefore reduce the load on your image server.

Put this in your .htaccess file:

<IfModule mod_expires.c>
        ExpiresActive on
        ExpiresByType image/gif "access plus 10 years"
        ExpiresByType image/jpeg "access plus 10 years"
        ExpiresByType image/png "access plus 10 years"
        ExpiresByType text/css "access plus 10 years"
        ExpiresByType text/js "access plus 10 years"
        ExpiresByType text/javascript "access plus 10 years"
        ExpiresByType application/javascript "access plus 10 years"
        ExpiresByType application/x-javascript "access plus 10 years"
        #ExpiresDefault "access plus 1 days"
</IfModule>

Post new comment

  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <css>, <diff>, <drupal5>, <html>, <javascript>, <php>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • You may use [img:xx] tags to display uploaded files or images inline.
  • Allowed HTML tags: <b> <br> <p> <a> <strong> <cite> <em> <code> <ul> <ol> <li> <dl> <dt> <dd>

More information about formatting options