【问题标题】:Setting expires header for a specific URI?为特定 URI 设置过期标头?
【发布时间】:2010-12-08 17:17:26
【问题描述】:

我正在尝试为特定 URI 设置过期标头,但由于某种原因它不起作用,到目前为止我在 httpd.conf 文件中所做的如下:

<LocationMatch "/mysite/contentservices/weather/get.json">
  ExpiresDefault A86400
</LocationMatch>

<LocationMatch "/mysite/*">
  Options FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  Allow from all
  ExpiresByType text/css "access plus 1 day"
  ExpiresByType text/javascript "access plus 1 day"
  ExpiresByType image/gif "access plus 1 week"
  ExpiresByType image/jpg "access plus 1 week"
  ExpiresByType image/png "access plus 1 week"
  ExpiresByType application/x-shockwave-flash "access plus 1 week"
</LocationMatch>

这根本不适合我。我指定的内容没有到期日期标题。我也不明白当你有两个重叠的 LocationMatch 指令时会发生什么,第一个指令优先?

【问题讨论】:

    标签: apache configuration


    【解决方案1】:

    我不确定,但文档没有提到 LocationMatch 作为可能的上下文。

    "上下文:服务器配置、虚拟主机、目录、.htaccess"

    http://httpd.apache.org/docs/2.0/mod/mod_expires.html

    【讨论】:

      【解决方案2】:

      我假设 /mysite/contentservices/weather/get.json 是一个静态数据文件,而不是由 CGI / mod_php / 其他东西提供服务?

      配置按照它们在配置文件中的顺序应用。

      http://httpd.apache.org/docs/2.0/sections.html

      虽然没有其他因素,但参数的不同格式应该不是问题,但如果您尝试,可能值得检查会发生什么:

      <LocationMatch "/mysite/contentservices/weather/get.json">
        ExpiresDefault "access plus 1 day"
      </LocationMatch>
      

      C.

      【讨论】:

        【解决方案3】:

        尝试切换 LocationMatch 括号。

        或者:一些代理服务器删除 expires-header。

        【讨论】:

        • 你能举个例子吗?
        • 你的意思是他应该把 get.json 放在 /mysite/* 或其他东西之后吗?
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-09-02
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多