Apache:ExpiresDefault 不起作用,而 "Header"起作用。怎么会?

标签 apache httpd.conf

如果我这样做:

<IfModule mod_expires.c>
  <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4|css|js|php)$">
    ExpiresActive On
    ExpiresDefault "access plus 30 days"
  </FilesMatch>
</IfModule>

它没有正确设置 Expire header ,而如果我像这样手动“强制”它:
<IfModule mod_expires.c>
  <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4|css|js|php)$">
    ExpiresActive On
    Header set Expires "Thu, 18 Jan 2012 20:00:00 GMT"
  </FilesMatch>
</IfModule>

有用。这意味着两件事:
  • mod_expire 已安装(IfModule mod_expires.c 为真)
  • 过期标题是 不是 应用此规则后修改。

  • 我错过了什么?

    顺便说一句:如果您有任何解决方案可以使其发挥作用,我就是您的男人!

    最佳答案

    好的,我从官方文档 here 中得到了它:

    Note that if you use a modification date based setting, the Expires header will not be added to content that does not come from a file on disk. This is due to the fact that there is no modification time for such content.



    所以它只适用于静态文件,而不适用于所有其他文件:它们不是静态的。

    关于Apache:ExpiresDefault 不起作用,而 "Header"起作用。怎么会?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8822559/

    相关文章:

    apache - 如何检查客户端是否在 apache 服务器中处于饥饿状态?

    linux - 如果我的 cpu 使用率在 linux 服务器上保持 100% 30 分钟左右会发生什么

    php - Apache 权限被拒绝

    perl - 如何在不重新启动的情况下调试 mod_perl2 模块?

    apache - Apache网络服务器中的KeepAliveTimeout 0

    linux - httpd/apachectl 服务无法在 RHEL 7 上启动

    apache - 无法使用 apache/centos 提供 https

    apache - SSL:我可以在同一台服务器上对 Web 和邮件服务使用相同的 SSL 证书吗?

    sleep 和循环期间的 PHP 内存使用情况

    Apache 无法访问 Tomcat : AH00957, AH00959 和 AH00896