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

I've put in httpd.conf

# 480 weeks
<filesmatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=290304000, public"

# 2 days
<filesmatch "\.(xml|txt)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"

# 2 hours
<filesmatch "\.(html|htm)$">
Header set Cache-Control "max-age=7200, must-revalidate"

but when I run /etc/init.d/apache restart (in Debian 6.0) I get:

Syntax error on line 3 of /etc/apache2/httpd.conf:
Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
share|improve this question
up vote 2 down vote accepted

To use Header directive you need to load mod_headers:

sudo a2enmod headers
share|improve this answer
a2enmod headers fix it. – Fred Collins May 13 '11 at 17:50

Line 3? Try moving the above config to the end of your httpd.conf. The necessary modules haven't loaded yet at the top of the file. Also it's good to put snippets like this up and over in files under /etc/apache2/conf.d, so you're not modifying stock files, but you can tackle that after.

share|improve this answer
What module should I load? – Fred Collins May 13 '11 at 1:07
Googling for "apache Header" yielded mod_headers, so I'd check for that. I'd be surprised if it wasn't already loaded. For example my Apache has "LoadModule headers_module modules/". – Steve Kehlet May 13 '11 at 22:34

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.