Google app engine 如何在GAE中启用浏览器缓存

Google app engine 如何在GAE中启用浏览器缓存,google-app-engine,Google App Engine,虽然这个问题应该很简单,但我并没有成功地在web google app engine java服务器上启用浏览器缓存 我尝试将此类内容放在appengine-web.xml中: <static-files> <include path="/**.cache.**" expiration="365d" /> ... 这很好。。。但在生产环境中: HTTP/1.1 304 Not Modified ETag: "RV4Bpg" X-AppEngine-Estimated

虽然这个问题应该很简单,但我并没有成功地在web google app engine java服务器上启用浏览器缓存

我尝试将此类内容放在appengine-web.xml中:

<static-files>
  <include path="/**.cache.**" expiration="365d" />
...
这很好。。。但在生产环境中:

HTTP/1.1 304 Not Modified
ETag: "RV4Bpg"
X-AppEngine-Estimated-CPM-US-Dollars: $0.000000
X-AppEngine-Resource-Usage: ms=109 cpu_ms=0
Date: Thu, 10 Jan 2013 19:41:20 GMT
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Cache-Control: no-cache, must-revalidate
Server: Google Frontend
这绝对不是我想要的:(

知道吗?我错过了什么

[编辑] 对于尚未下载的内容,“我的浏览器”将收到以下标题:

HTTP/1.1 200 OK
ETag: "RV4Bpg"
Date: Fri, 11 Jan 2013 12:50:50 GMT
Expires: Sat, 11 Jan 2014 12:50:50 GMT
Cache-Control: public, max-age=31536000
X-AppEngine-Estimated-CPM-US-Dollars: $0.000000
X-AppEngine-Resource-Usage: ms=3 cpu_ms=0
Date: Fri, 11 Jan 2013 12:50:50 GMT
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Cache-Control: no-cache, must-revalidate
Content-Type: image/png
Server: Google Frontend
Content-Length: 196084
Proxy-Connection: Keep-Alive
Connection: Keep-Alive
X-RBT-Optimized-By: eu-dcc-sh02 (RiOS 6.5.5b) SC
一个ETag和几个相互矛盾的“过期”和“缓存控制”。。。
有几种方法可以配置缓存策略吗?它可能来自我的ISP还是代理?

是的,
缓存控制关闭,因为回复是HTTP 304

问题是您的浏览器保存了ETag:

现在,对于相同url/内容的每个请求,浏览器都提供ETag和GAE回复,HTTP 304未修改

尝试更改此url处的资源(图像),检查尚未加载到此浏览器中的其他url,或使用其他浏览器或计算机


此外,这也是相关的:

当您以管理员身份登录到Google App Engine应用程序时:

  • 包括问题中显示的
    X-AppEngine-*
    标题
  • Cache Control:no Cache,must revalidate
    头被包括在内,因为
    X-AppEngine-*
    头是私有的,不能被缓存
  • 这隐藏在的“答复”部分的末尾,该部分表示:

    具有资源使用统计信息的响应将被设置为不可缓存


    感谢您增强此ETag功能。对于新内容,浏览器将收到ETag并过期。(我现在不会发布标题,因为我没有类似的情况。例如代理)我将完成我的问题。可能重复的问题与问题中的问题类似,我想指出的是,即使您没有以GAE管理员身份登录(例如,使用Chrome作为来宾或注销或其他方式),你仍然可以得到304。在我的例子中,我使用了Chrome,没有以GAE管理员的身份登录,让开发工具打开,“禁用缓存(而DevTools是打开的)”被取消选中。仍然是304。我发现原因是当点击cmd+R(或ctrl+R)时浏览器不使用缓存。请尝试单击浏览器的url字段,然后按enter键,所有这些304现在都应为200(缓存)。
    HTTP/1.1 200 OK
    ETag: "RV4Bpg"
    Date: Fri, 11 Jan 2013 12:50:50 GMT
    Expires: Sat, 11 Jan 2014 12:50:50 GMT
    Cache-Control: public, max-age=31536000
    X-AppEngine-Estimated-CPM-US-Dollars: $0.000000
    X-AppEngine-Resource-Usage: ms=3 cpu_ms=0
    Date: Fri, 11 Jan 2013 12:50:50 GMT
    Pragma: no-cache
    Expires: Fri, 01 Jan 1990 00:00:00 GMT
    Cache-Control: no-cache, must-revalidate
    Content-Type: image/png
    Server: Google Frontend
    Content-Length: 196084
    Proxy-Connection: Keep-Alive
    Connection: Keep-Alive
    X-RBT-Optimized-By: eu-dcc-sh02 (RiOS 6.5.5b) SC