相关疑难解决方法(0)

使用Flask,如何修改ALL输出的Cache-Control标头?

我试过用这个

@app.after_request
def add_header(response):
    response.headers['Cache-Control'] = 'max-age=300'
    return response
Run Code Online (Sandbox Code Playgroud)

但这会导致出现重复的Cache-Control标头.我只想要max-age = 300,而不是max-age = 1209600行!

$ curl -I http://my.url.here/
HTTP/1.1 200 OK
Date: Wed, 16 Apr 2014 14:24:22 GMT
Server: Apache
Cache-Control: max-age=300
Content-Length: 107993
Cache-Control: max-age=1209600
Expires: Wed, 30 Apr 2014 14:24:22 GMT
Content-Type: text/html; charset=utf-8
Run Code Online (Sandbox Code Playgroud)

python http flask

30
推荐指数
2
解决办法
2万
查看次数

标签 统计

flask ×1

http ×1

python ×1