Apache ExpiresDefault A0 不起作用
Posted
技术标签:
【中文标题】Apache ExpiresDefault A0 不起作用【英文标题】:Apache ExpiresDefault A0 does not work 【发布时间】:2017-12-13 15:51:50 【问题描述】:我正在设置 apache 标头,不想缓存 php、CGI、Python 或任何动态文件。
我正在使用服务器:Debian 9
我已经添加了这个配置:
# No caching for dynamic files
<filesMatch "\.(php|cgi|pl|htm)$">
ExpiresDefault A0
Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
Header set Pragma "no-cache"
</filesMatch>
但显示以下错误:
AH00526: Syntax error on line 86 of /etc/apache2/conf-enabled/headers.conf: Invalid command 'ExpiresDefault', perhaps misspelled or defined by a module not included in the server configuration Action '-t' failed.
我该如何解决这个错误?
【问题讨论】:
为什么你认为这不起作用?语法对我来说很好,但如果您需要解决方案的帮助,请解释问题。您是否打开了 ExpiresActive 标志 (httpd.apache.org/docs/current/mod/…)? AH00526:/etc/apache2/conf-enabled/headers.conf 第 86 行的语法错误:无效命令“ExpiresDefault”,可能拼写错误或由服务器配置操作中未包含的模块定义-t' 失败。 我正在使用这个Apache配置文件github.com/gregrickaby/The-Perfect-Apache-Configuration 【参考方案1】:您需要启用 mod_expiries。
从 httpd.conf 中取消注释以下行:
LoadModule expires_module modules/mod_expires.so
或者如果在基于 Debian 的系统上,则使用以下命令启用它:
a2enmod expires
【讨论】:
以上是关于Apache ExpiresDefault A0 不起作用的主要内容,如果未能解决你的问题,请参考以下文章