Search code examples
google-apps-scriptcachingurlfetch

Caching in UrlFetchApp


In Google App Script I'm using UrlFetchApp() to bring in some code served from an outside host. I make changes to the code served on that host but these aren't appearing in the code run by script.

My server logs show that the desired is sometimes requested (and served) but it isn't showing up in the script.

I'm using optAdvancedArgs in my UrlFetchApp call, passing in {"headers" : {"Cache-Control": "no-cache"}

but this isn't helping.

Is there some kind of caching of resources obtained by UrlFetchApp(), and if so how can I turn it off?


Solution

  • Setting the header Cache-Control to max-age=1 seemed to fix the problem.

    This discussion provided some helpful context: https://developers.google.com/speed/docs/best-practices/caching