2017-07-10 45 views
1

我設置了Apache頭文件,並且不想緩存PHP,CGI,Python或任何動態文件。Apache ExpiresDefault A0不起作用

我使用的服務器: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. 

我怎麼解決這個問題?

+0

爲什麼你認爲不工作?語法對我來說看起來很好,但如果您需要解決方案的幫助,請解釋問題。您是否打開了ExpiresActive標誌(http://httpd.apache.org/docs/current/mod/mod_expires.html#expiresactive)? –

+0

AH00526:/etc/apache2/conf-enabled/headers.conf中第86行的語法錯誤: 無效的命令'ExpiresDefault',可能是拼寫錯誤或未包含在服務器配置中的模塊定義的 操作'-t'失敗。 – brody

+0

我正在使用這個Apache配置文件https://github.com/gregrickaby/The-Perfect-Apache-Configuration – brody

回答

1

您需要啓用mod_expiries。

取消對以下行從httpd.conf中:

LoadModule expires_module modules/mod_expires.so 

或者,如果基於Debian的系統上,然後用下面的命令啓用它:

a2enmod expires