Search code examples
google-app-enginecachinggoogle-cloud-platform

Google app engine - how to disable the cache


So some context:

I have a nodeJS api running on a google app engine. All my get requests are being cached by default by the app engine for 10 minutes.

I am using cloudflare for my API as this allows me to remove specific items from the cache when needed.

You can imagine this has caused a bit of an issue because my CF cache was correctly cleared but the app engine kept returning old data.

According to the docs, you can set a default_expiration in the app.yaml file but setting this to 0 or 0s has made no difference and google keeps caching my responses.

Seemingly, there is also no way you can get something uncached from google.

Now my obvious question here is: is there some way I can completely ignore this cache? Preferrably without having to set my entire API's response to private , 0s cache.

It quite irks me that google is forcing this cache on me provides very vague documentation on the whole matter.


Solution

  • You can configure your app.yaml to define a cache period.

    If you use default_expiration this will set a global default cache period for all static file handlers for an application. If omitted, the production server sets the expiration to 10 minutes by default.

    To set specific expiration times for individual handlers, specify the expiration element within the handler element in your app.yaml file. You can change the duration of time web proxies and browsers should cache a static file served by this handler.

    default_expiration: "4d 5h"
    
    handlers:
    - url: /stylesheets
      static_dir: stylesheets
      expiration: "0d 0h"