Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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"
</filesmatch>

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

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

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.
 failed!
share|improve this question

2 Answers 2

up vote 1 down vote accepted

To use Header directive you need to load mod_headers:

sudo a2enmod headers
share|improve this answer
2  
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/mod_headers.so". –  Steve Kehlet May 13 '11 at 22:34

Your Answer

 
discard

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.