Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is for Apache: <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$"> Header set Cache-Control "max-age=290304000, public" </FilesMatch>

How do I do it for lighttpd?

share|improve this question
up vote 3 down vote accepted

It should acutally be quite easy with a regular expression on $HTTP["url"] and mod_setenv:

$HTTP["url"] =~ "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$" {
  setenv.add-response-header = ( "Cache-Control" => "max-age=290304000, public" )

If you need to manipulate the requests or responses in more detail, you should dig into mod_magnet.

Documentation hints:

share|improve this answer
I think the semantics of setenv.add-response-header in lighttpd and "Header set" in apache are different. The former adds a header, even if it already exists. The latter replaces what was in the header, or adds it if it was not present before. – rmalayter Mar 22 '11 at 22:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.