mod_never_expire

Remember mod_images_never_expire?

Well Today I wrote mod_never_expire . Its pretty much the same idea, but its a little more configurable, and for files it sets long expire and cache-control headers…. And it works in httpd 2.x

To use, you just use any Directory/Location/Files container, and tur it on:

  <LocationMatch ^/c/css/r\d+/.+\.css>
    NeverExpire on
  </LocationMatch>

or:

  <Directory "/foo/bar/js/">
    NeverExpire on
  </Directory>

Great for Images, CSS, and Javascript, as long as you properly version your URLs.

This entry was posted in Uncategorized. Bookmark the permalink.

6 Responses to mod_never_expire

  1. Excellent. Also see brief discussion here on immutability:
    http://www.mnot.net/blog/2007/05/15/expires_max-age

  2. Paul Querna says:

    I did, but it has two main problems:
    1. It’s complicated.
    2. It by default wants to work per-content Content-Types, when really for me, everything under a directory path is what matters.

  3. Eric Lemoine says:

    By default you can make it work by directory if you want :

    ExpiresActive Off
    ExpiresDefault “access plus 10 years”

    ExpiresActive On

  4. Eric Lemoine says:

    Sorry your blog skipped my directory directive :

    ExpiresActive Off
    ExpiresDefault “access plus 10 years”
    < Directory “/foo/bar/js/” >
    ExpiresActive On
    < /Directory >

  5. Geoff says:

    I hope you have some tests :)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>