Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why Webapp2 redirect to a page but it's not reload?

Tags:

webapp2

I am using a webapp2 in GAE, when I called self.redirect to some page like below:

self.redirect(some_url)

which returned a page looks like cached, I have to refresh/reload the page so that I would get latest data.

Is there any cache setting for webapp2? or I have to set some properties for response of that page? Please advise.

like image 629
Cooper.Wu Avatar asked Dec 15 '22 10:12

Cooper.Wu


1 Answers

In my project I've fixed that by adding time.sleep(0.1) just before the self.redirect('someurl') call.

Not sure if it is a best way to solve the problem, but pages started to show most recent info.


Edit: beware of consistency issue

Check out @Lindsay answer. Using time.sleep(0.1) might give you the expected result in a local environment, but you cannot trust it in a production environment. If you really need results to be strongly consistent, use an ancestor query, not time.sleep(0.1).

like image 176
Stanley Kirdey Avatar answered Dec 31 '22 14:12

Stanley Kirdey