GAE Java SDK:appengine-web.xml&#34; <static-file> </static-file>

时间:2012-09-28 15:34:13

标签: java google-app-engine

我正在使用Google App Engine Java SDK 1.7.2来提供一些静态文件。在appengine-web.xml中<include...下合并多个<static-files>元素时,我不确定哪些规则优先。

例如,我有以下内容:

<static-files>
  <include path="/**.swf" expiration="365d"></include>
  <include path="/**.jpg" expiration="365d"></include>
  <include path="/**"></include>    
  <exclude path="/**.php"></exclude>
</static-files>

我相信这指定一切都应该包含在静态存储中,除了.php文件,并且.swf和.jpg文件应该在将来365天设置“cache-control”和“expires”http标头。 / p>

但是,当使用Firefox的Live HTTP Headers工具时,我看不到具有长期过期的静态文件的预期标头:

http://localhost:8888/swf/Logo.20120927.swf

GET /swf/Logo.20120927.swf HTTP/1.1
Host: localhost:8888
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:15.0) Gecko/20100101 Firefox/15.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-gb,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
DNT: 1
Connection: keep-alive
Referer: http://localhost:8888/
If-Modified-Since: Thu, 27 Sep 2012 15:49:03 GMT
Cache-Control: max-age=0

HTTP/1.1 304 Not Modified
Server: Jetty(6.1.x)
----------------------------------------------------------
http://localhost:8888/images/logo-and-buttons.20120927.jpg

GET /images/logo-and-buttons.20120927.jpg HTTP/1.1
Host: localhost:8888
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:15.0) Gecko/20100101 Firefox/15.0.1
Accept: image/png,image/*;q=0.8,*/*;q=0.5
Accept-Language: en-gb,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
DNT: 1
Connection: keep-alive
Referer: http://localhost:8888/
If-Modified-Since: Thu, 27 Sep 2012 15:49:03 GMT
Cache-Control: max-age=0

HTTP/1.1 304 Not Modified
Server: Jetty(6.1.x)

我的问题是,如果这不按预期运行,那么如何配置我的<static-files>元素以达到预期效果?

干杯,

杰夫。

1 个答案:

答案 0 :(得分:0)

我已经回答了我自己的问题:我的“缓存控制:max-age”值为0,而我的HTTP标头中没有“过期”值的原因是因为我只是在Firefox中重新加载页面。在开始新的私人浏览会话(在此过程中重置缓存)并首次加载页面时,我收到了预期的标题。