Use the response.cache_control
object; this is a ResponseCacheControl()
instance letting you set various cache attributes directly. Moreover, it’ll make sure not to add duplicate headers if there is one there already.
@app.after_request
def add_header(response):
response.cache_control.max_age = 300
return response