api: Cache-Control no-store on /api/history (mutable JSON must not be cached)
This commit is contained in:
1 parent
0a86e70a54
commit
ca86daf9a6
1 file changed
+5
-1
+5
-1
@@ -136,7 +136,11 @@ def _save_hist(user: str, entries):
|
||||
|
||||
@app.get("/api/history")
|
||||
def api_history(request: Request):
|
||||
return sorted(_load_hist(request.state.user), key=lambda e: e.get("t", 0), reverse=True)[:5]
|
||||
# no-store: this JSON mutates while a tab is open (position saves);
|
||||
# a stale copy has caused "poster gone" confusion before
|
||||
return JSONResponse(
|
||||
sorted(_load_hist(request.state.user), key=lambda e: e.get("t", 0), reverse=True)[:5],
|
||||
headers={"Cache-Control": "no-store"})
|
||||
|
||||
|
||||
@app.post("/api/history")
|
||||
|
||||
Reference in new issue
Block a user