缓存控制apache错误

Fre*_*ins 1 cache apache-2.2

我已经输入了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>
Run Code Online (Sandbox Code Playgroud)

但是当我运行时/etc/init.d/apache restart(在 Debian 6.0 中)我得到:

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!
Run Code Online (Sandbox Code Playgroud)

Ale*_*exD 5

要使用Header指令,您需要加载mod_headers

sudo a2enmod headers
Run Code Online (Sandbox Code Playgroud)

  • `a2enmod headers` 修复它。 (2认同)