pythonurllib2将“nocache”添加到请求头不会

2024-05-15 21:10:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用的是python2.7.3和varnish-3.0.2。在

我正在使用pythonurllib2库。在

我希望强制服务器从数据库中带回最新的数据,而不是使用varnish缓存,所以我在请求中添加了以下内容

    req.add_header('Pragma', 'no-cache');
    req.add_header('Cache-Control', 'no-cache');

但这不起作用-没有效果。在

下面是一个代码片段:

^{pr2}$

下面是请求头:

header: Server: nginx/1.1.19
header: Date: Mon, 12 Jan 2015 17:51:22 GMT
header: Content-Type: application/json
header: Content-Length: 636
header: Connection: close
header: Vary: Accept
header: ETag: "acfa981667dfb6de47881623ad092672"
header: Allow: HEAD, GET, OPTIONS
header: Cache-Control: s-maxage=604800, public, max-age=300
header: Accept-Ranges: bytes
header: X-Varnish: 1115442413
header: Age: 0
header: Via: 1.1 varnish
header: X-Varnish-Cache: MISS

我的回复中没有收到最新的数据-有人能帮忙吗? 非常感谢。在


Tags: 数据no服务器add数据库cachecontentreq