为特定URI设置过期标头?

5

我正在尝试为特定的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指令时会发生什么,第一个指令会优先执行吗?

3个回答

2

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.


0
尝试交换 LocationMatch 括号。
或者:一些代理服务器会删除过期标头。

你能给我一个例子吗? - Yaniv Cohen
你的意思是他应该把get.json放在/mysite/*之后还是其他什么地方? - David Rabinowitz

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接