【问题标题】:Apache ExpiresDefault A0 does not workApache ExpiresDefault A0 不起作用
【发布时间】: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

标签: apache2.4


【解决方案1】:

您需要启用 mod_expiries。

从 httpd.conf 中取消注释以下行:

LoadModule expires_module modules/mod_expires.so

或者如果在基于 Debian 的系统上,则使用以下命令启用它:

a2enmod expires

【讨论】:

    猜你喜欢
    • 2011-12-17
    • 2015-06-07
    • 2011-03-30
    • 2011-06-29
    • 1970-01-01
    • 1970-01-01
    • 2016-12-17
    • 2015-04-23
    • 2012-12-30
    相关资源
    最近更新 更多