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!
link|improve this question

80% accept rate
feedback

2 Answers

up vote 0 down vote accepted

To use Header directive you need to load mod_headers

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

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.

link|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
feedback

Your Answer

 
or
required, but never shown

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