【问题标题】:How to unset Cache-Control max-age in .htaccess?如何在 .htaccess 中取消设置 Cache-Control max-age?
【发布时间】:2011-03-12 04:09:54
【问题描述】:

我正在尝试通过 .htaccess 取消设置 Cache-Control 的 max-age。以下内容完全删除了 Cache-Control:

Header unset Cache-Control

如何告诉它只删除“max-age”?谢谢。

【问题讨论】:

    标签: apache .htaccess http-headers


    【解决方案1】:

    在 Apache 2.2.4 中有一个新的 标题编辑 操作,可以让您完全执行这些操作。

    来自Apache documentation如果这个请求头存在,它的值会根据正则表达式search-and-replace进行转换。 value参数是正则表达式,replacement是替换字符串,可能包含反向引用。

    但是,所需的正则表达式会相当复杂。因此我建议只使用 Header set 来覆盖当前的 Cache-Control 如果你可以硬编码值。使用 set 操作会覆盖之前包含 max-age 的值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-04-08
      • 2021-01-08
      • 1970-01-01
      • 2018-05-01
      • 1970-01-01
      • 2012-06-30
      • 2020-08-11
      相关资源
      最近更新 更多