diff --git a/bemani/api/app.py b/bemani/api/app.py index 9027938..1286d1e 100644 --- a/bemani/api/app.py +++ b/bemani/api/app.py @@ -46,6 +46,15 @@ def before_request() -> None: 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 def teardown_request(exception: Any) -> None: data = getattr(g, 'data', None) diff --git a/bemani/frontend/app.py b/bemani/frontend/app.py index 8d3d7c7..c968427 100644 --- a/bemani/frontend/app.py +++ b/bemani/frontend/app.py @@ -47,6 +47,17 @@ def before_request() -> 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 def teardown_request(exception: Any) -> None: data = getattr(g, 'data', None)