Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

populate ETAG and LAST-MODIFIED for assests #17

Closed
Andersmholmgren opened this issue Nov 16, 2014 · 2 comments
Closed

populate ETAG and LAST-MODIFIED for assests #17

Andersmholmgren opened this issue Nov 16, 2014 · 2 comments

Comments

@Andersmholmgren
Copy link

I can't get caching to work for my assets serviced from the appengine context. Unless there is some magic that is intended to occur in Googles CDN then I imagine the reason is that appengine / shelf_appengine do not populate ETAG and LAST-MODIFIED on the assets

@sgjesse
Copy link
Contributor

sgjesse commented Dec 2, 2014

I have now looked into this issue, and there are a number of requirements on the request to make it cachable:

  • Date header is required (and must not be in the future)
  • Cache-Control: public must be set
  • The max age must be defined using either Cache-Control: s-maxage, Cache-Control: max-age or Expires:

There are a number of exemptions, e.g. only some status codes will cause caching. For instance status code 304 is not cachable. So to make use of the cache status code 200 including the full resource must be served from the application for the resource to be inserted into the cache. When the cache expires the If-Modified-Since header will most likely be in the request, and if a 304 response is returned no caching will happen.

Also some values for the Vary header and the presence of the Set-Cookie header will prevent caching. Finally only GET (not HEAD) will cause caching. However HEAD requests can be served from the cache when the resource is cached.

One thing to note is that for App Engine the cache will talk to App Engine and tell which resources was served out of the cache. So even when served from the cache the request will be in the logs in the cloud console.

One way to test caching is to have logging in the request handler code, and see that the request is in the log, but the actual request handler is not called.

Another way to see that the resource is coming from the cache is that the Age header is present in the response. Of cause the Age header might not originate from the Google cache but could also be from another cache.

@sigurdm
Copy link

sigurdm commented Sep 30, 2021

shelf_appengine has been discontinued.
Closing as assumed stale.

@sigurdm sigurdm closed this as completed Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants