I am using UrlFetchApp in a google apps script to perform a get, as follows:
var optAdvancedArgs = {
"method": "GET",
"headers": {"Cache-Control": "no-cache", "Pragma": "no-cache"},
};
var response = UrlFetchApp.fetch(url, optAdvancedArgs);
Despite my attempt to disable the cache in the headers, the response I get is always a cached copy. If I perform a wget in my console using the same url, I see receive an up to date version.
My question is: How can I really disable the cache when performing a UrlFetchApp.fetch? Is there something wrong with my code?
I was able to overcome this issue by using "max-age=0" in my Cache-Control header, eg:
var url = "http://www.stackoverflow.com";
var options =
{
// Ensure we get a fresh copy of the site every time.
headers : {'Cache-Control' : 'max-age=0'}
};
var response = UrlFetchApp.fetch(url, options)
It sounds like Google App Engine has a similar problem . Someone opened an issue however it appears to have been closed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.