Add cache control headers to force unruly clients like android to reload REST responses every time.
This commit is contained in:
parent
069fbb4ba1
commit
479ba60b05
@ -46,6 +46,15 @@ def before_request() -> None:
|
|||||||
g.authorized = g.data.local.api.validate_client(authtoken)
|
g.authorized = g.data.local.api.validate_client(authtoken)
|
||||||
|
|
||||||
|
|
||||||
|
@app.after_request
|
||||||
|
def after_request(response: Response) -> Response:
|
||||||
|
# Make sure our REST responses don't get cached, so that remote
|
||||||
|
# servers which respect cache headers don't get confused.
|
||||||
|
response.cache_control.no_cache = True
|
||||||
|
response.cache_control.must_revalidate = True
|
||||||
|
response.cache_control.private = True
|
||||||
|
|
||||||
|
|
||||||
@app.teardown_request
|
@app.teardown_request
|
||||||
def teardown_request(exception: Any) -> None:
|
def teardown_request(exception: Any) -> None:
|
||||||
data = getattr(g, 'data', None)
|
data = getattr(g, 'data', None)
|
||||||
|
@ -47,6 +47,17 @@ def before_request() -> None:
|
|||||||
g.userID = None
|
g.userID = None
|
||||||
|
|
||||||
|
|
||||||
|
@app.after_request
|
||||||
|
def after_request(response: Response) -> Response:
|
||||||
|
if not response.cache_control.max_age:
|
||||||
|
# Make sure our REST calls don't get cached, so that the
|
||||||
|
# live pages update in real-time.
|
||||||
|
response.cache_control.no_cache = True
|
||||||
|
response.cache_control.must_revalidate = True
|
||||||
|
response.cache_control.private = True
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
@app.teardown_request
|
@app.teardown_request
|
||||||
def teardown_request(exception: Any) -> None:
|
def teardown_request(exception: Any) -> None:
|
||||||
data = getattr(g, 'data', None)
|
data = getattr(g, 'data', None)
|
||||||
|
Loading…
Reference in New Issue
Block a user