google-app-engine

EdgeCache

Remarks#

Details

  • When Edge Cache is enabled and working, App Engine sends an age header whose value is the time (in seconds) since the response has been cached. For example, if the response has been cached for two minutes thus far, the response will include a header of age: 120. If no age header is being sent, it’s a good sign that you haven’t gotten Edge Cache to work yet. Additionally, when the response doesn’t include an age header, it means the request missed Edge Cache.
  • Edge Cache doesn’t work in the local development environment.
  • There are different caches for different regions. There are separate caches for separate regions of the world. For example, a request from Europe might be hit the cache, while a request at the exact same time from Australia may not hit Edge Cache.
  • There are multiple caches even in the same region. For example, two sequential requests from the same client may receive responses with different values for the age header.
  • Google evicts content from Edge Cache before the max-age has been reached. This is especially true if the resource has not been requested for more than 5 minutes.
  • Google automatically sends a Vary header with the value Accept-Encoding with some responses. See this documentation.
  • App Engine will not allow you to set the Cache-Control header to public if you also have a Set-Cookie header present. App Engine will even change the value of the Cache-Control header from public to private if there is a Set-Cookie header. See here.

How EdgeCache works

EdgeCache is a reverse proxy cache that stores data for a certain period of time, and returns it quickly upon seeing the same request as long as the cache is still valid.

Here is a diagram from this video from the App Engine team about how EdgeCache works:

EdgeCache Diagram

The “Google Front End” data centers are located around the world and can store cached data to be returned quickly upon request without ever having to run any of your App Engine code (which runs on the “App Engine Front End”).

See this StackOverflow answer for more information about reverse proxies in general.

Current Situation

Unfortunately, the current state of knowledge about GAE’s EdgeCache is pretty bad. The extent of the documentation on this secretive feature can be found in this forum post (read it now!) from 2011 and the 24 seconds between 11:11 and 11:35 in this video from Google.

More Resources

Below is the list of more resources we’ve found pertaining to App Engine’s EdgeCache feature:

Enabling EdgeCache

  • In order to enable EdgeCache, set the following HTTP response headers (Do not deviate from this exact format):
    • Cache-Control header to public, max-age=X where:
      • X = the number of seconds that you want the response to be cached for
      • X > 60 seconds
      • X < 365*24*60*60
    • Set the Pragma header to Public.

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow