Question

I wonder know, if Google App Engine's service URL Fetch uses proxy cache, which is discussed in other thread? My question is: if I send request using URL Fetch from my app on GAE to my app (to some handler), will the result be cached in this proxy?

Thanks.

Was it helpful?

Solution

This will work as long as you set the Cache-Control header and you are not requesting the same url (i.e., url foo from foo).

However I would recommend to cache the response of the desired webpages using memcache instead. This will be much faster than calling urlfetch and will give you better control and guarantees.

OTHER TIPS

Set an appropriate Cache-control header on URLFetch:

Python

result = urlfetch.fetch(url, headers = {'Cache-Control' : 'max-age=0, must-revalidate'})

GO

client := urlfetch.Client(c)
req, err := http.NewRequest("GET", check.Url, nil)
req.Header.Add("Cache-Control", `max-age=0, must-revalidate`)
resp, err := client.Do(req)

I'm just speculating on your application's design here, but why would you need to use the UrlFetch API to retrieve something you could easily get instantiating and using your business logic classes directly?

Also note this from the Urlfetch documentation:

To prevent an app from causing an endless recursion of requests, a request handler is not allowed to fetch its own URL.

If you are really forced to do this, then set the proper Cache-Control header on your request:

headers = {'Cache-Control':'no-cache,max-age=0', 'Pragma':'no-cache'}
result = urlfetch.fetch("http://foo/route", None, urlfetch.GET, headers)

Have a look to this Issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top