How to enable browser caching in GAE

Although this question should be trivial, I could not enable browser caching on the java server web server for Google.

I am trying to put this in my appengine-web.xml:

<static-files> <include path="/**.cache.**" expiration="365d" /> ... 

but when I look at the response header, I find this local:

 Content-Length: 196084 Cache-Control: public, max-age=31536000 Expires: Fri, 10 Jan 2014 19:40:45 GMT Content-Type: image/png Last-Modified: Tue, 18 Dec 2012 21:41:22 GMT Server: Jetty(6.1.x) 

Which is good ... but this is in a production environment:

 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 

Which is finally not what I want: (

Any idea? Did I miss something?

[EDIT] For content not yet uploaded, my browser receives the following header:

 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 and several conflicting "Expires" and "Cache-Control" ... Are there several ways to configure a caching policy? Could this come from my ISP? or proxy?

+6
source share
2 answers

When you log in to the Google App Engine app as an administrator:

  • The X-AppEngine-* headers provided in your question are included.
  • The Cache-Control: no-cache, must-revalidate header Cache-Control: no-cache, must-revalidate enabled because the X-AppEngine-* headers are private and should not be cached.

This is hidden at the end of the Answers section of https://developers.google.com/appengine/docs/python/runtime#Responses , which states that:

Responses with resource usage statistics will be made invulnerable.

+9
source

Yes, Cache-Control disabled because the response is HTTP 304.

The problem is that your browser has saved ETag: http://en.wikipedia.org/wiki/HTTP_ETag

Now, for every request for the same URL, the browser provides ETag and GAE responses with HTTP 304 Not Modified.

Try changing the resource (image) at this URL by checking for a different URL that you have not yet downloaded in this browser, or that you have not used another browser or computer at all.

Also, it matters: What matters: ETag header or Last-Modified HTTP?

+2
source

All Articles