0

我正在 Google App Engine 上运行一个应用程序,并使用 GAE Utilities ( http://gaeutilities.appspot.com/ ) 设置一个 cookie,该 cookie 保存用户访问的唯一 ID。尽管在我测试它时它似乎工作正常,但我的 GAE 日志几乎在每次页面访问时都会出现错误。我得到的错误如下:

2013-04-21 12:00:28.568 /go/social/ag1zfnNwYXJrb21wYXNzch4LEgZDb3Vwb24iEmFmZmlsaW5ldDU3MjkyODgxMAw?src=TWT 200 658ms 1kb Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_6) AppleWebKit/534.24 (KHTML, like Gecko) Contact: feedback@getprismatic.com
184.73.14.223 - - [21/Apr/2013:03:00:28 -0700] "GET /go/social/ag1zfnNwYXJrb21wYXNzch4LEgZDb3Vwb24iEmFmZmlsaW5ldDU3MjkyODgxMAw?src=TWT HTTP/1.1" 200 1573 - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_6) AppleWebKit/534.24 (KHTML, like Gecko) Contact: feedback@getprismatic.com" "www.gutscheinalm.at" ms=659 cpu_ms=129 cpm_usd=0.000176 app_engine_release=1.7.7 instance=00c61b117c8b8fef32a0647ddfb82622596338
E 2013-04-21 12:00:28.566
Expires: Tue, 03 Jul 2001 06:00:00 GMTLast-Modified: Sun, 21 Apr 13 10:00:27 UTCCache-Control: no-store, no-cache, must-revalidate, max-age=0Cache-Control: post-check=0, pre-check=0Pragma: no-cache
E 2013-04-21 12:00:28.566
Set-Cookie: gaeutilities_session=ag1zfnNwYXJrb21wYXNzciMLEhtfQXBwRW5naW5lVXRpbGl0aWVzX1Nlc3Npb24Yp8kcDA_0b46176b54a9aa056a2af1b140ce9af1; expires=Sun, 21-Apr-2013 12:00:28 GMT; Path=/ 
E 2013-04-21 12:00:28.566
Set-Cookie: gaeutilities_session_data=; expires=Sun, 21-Apr-2013 12:00:28 GMT
E 2013-04-21 12:00:28.566
Expires: Tue, 03 Jul 2001 06:00:00 GMTLast-Modified: Sun, 21 Apr 13 10:00:28 UTCCache-Control: no-store, no-cache, must-revalidate, max-age=0Cache-Control: post-check=0, pre-check=0Pragma: no-cache

任何人都可以就导致此错误的原因以及可能的解决方法给我一些指示吗?非常感谢!

更新 1

我确定了调用它的代码,它位于 Sessions.py 第 523 行。目的是确保页面没有缓存在浏览器中。我注意到另一部分代码也使用“打印”命令,也将输入注册为错误。这是正常行为吗?

def no_cache_headers(self):
    """
    Generates headers to avoid any page caching in the browser.
    Useful for highly dynamic sites.

    Returns a unicode string of headers.
    """
    return u"".join([u"Expires: Tue, 03 Jul 2001 06:00:00 GMT",
        strftime("Last-Modified: %a, %d %b %y %H:%M:%S %Z").decode("utf-8"),
        u"Cache-Control: no-store, no-cache, must-revalidate, max-age=0",
        u"Cache-Control: post-check=0, pre-check=0",
        u"Pragma: no-cache",
    ])

# make sure the page is not cached in the browser
print self.no_cache_headers()
4

0 回答 0