0

I write an app with google app engine. It is a simple blog system. If I delete a piece of blog, the page didn't refresh as I wish. It still present the blog that has been deleted.But if I refresh the page after that, it will present in the correct way. I though it was the problem of cache. I have been working on it for serveral days. Could anyone teach me how to fix it? Thanks very much.

class BlogFront(BlogHandler):
    def get(self):
        val = self.request.get("newPost")
        #get all the pages
        posts = Post.all().order('-created')
        #stop the cache in the browser
        self.response.headers["Pragma"]="no-cache"
        self.response.headers["Cache-Control"]="no-cache, no-store, must-revalidate, pre-check=0, post-check=0"
        self.response.headers["Expires"]="Thu, 01 Dec 1994 16:00:00"
        self.render('front.html', posts = posts)

    def post(self):
        #press the delete button
        operatorRequest = self.request.get('Delete')
        articleId = operatorRequest.split('|')[0]
        operator = operatorRequest.split('|')[1]
        key = db.Key.from_path('Post', int(articleId), parent=blog_key())
        post = db.get(key)
        db.delete(post.key())
        self.redirect("/")
Dan McGrath
  • 41,220
  • 11
  • 99
  • 130
icystar
  • 231
  • 2
  • 2

1 Answers1

2

I assume redirect to / is handled by BlogFront handler. Seems you're hitting datastore eventual consistency.

Google App Engine Datastore: Dealing with eventual consistency

GAE: How long to wait for eventual consistency?

Community
  • 1
  • 1
marcadian
  • 2,608
  • 13
  • 20