Python请求历史记录转发,确保已禁用缓存

时间:2018-11-29 16:21:55

标签: python caching request

在我的python代码中,我向URL发出GET请求,我想知道最终转发的URL。 (获取request.history)

我已阅读-> Python Requests library redirect new urlhttp://docs.python-requests.org/en/latest/user/quickstart/#redirection-and-history

我已经在下面成功完成了。当python获取GET URL时,如何确保禁用缓存?

    response = requests.get(someurl)
if response.history:
    print "Request was redirected"
    for resp in response.history:
        print resp.status_code, resp.url
    print "Final destination:"
    print response.status_code, response.url
else:
    print "Request was not redirected"

如果我没记错的话,我必须使用标题

headers={'Cache-Control': 'no-cache'}

这是正确的吗?

0 个答案:

没有答案