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.

6 Responses to “mod_never_expire”

  1. Patrick Mueller Says:

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

  2. MikeD Says:

    Did you look at mod_expires ?
    http://httpd.apache.org/docs/2.0/mod/mod_expires.html

  3. 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.

  4. Eric Lemoine Says:

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

    ExpiresActive Off
    ExpiresDefault “access plus 10 years”

    ExpiresActive On

  5. Eric Lemoine Says:

    Sorry your blog skipped my directory directive :

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

  6. Geoff Says:

    I hope you have some tests :)

Leave a Reply