File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# stdlib
2+ import functools
23import itertools
34import json
45import os
1415 abort ,
1516 flash ,
1617 g ,
18+ make_response ,
1719 redirect ,
1820 render_template ,
1921 request ,
6769 geoturfs = json .load (f )
6870
6971
72+ def browser_cache (f ):
73+ @functools .wraps (f )
74+ def wrapped (* a , ** k ):
75+ r = f (* a , ** k )
76+ resp = make_response (r )
77+ if request .headers .get ("HX-Preloaded" ):
78+ resp .headers ["Cache-Control" ] = "private; max-age=60"
79+ return resp
80+
81+ return wrapped
82+
83+
7084@app .before_request
7185def before_request ():
7286 g .phonebank = False
@@ -387,6 +401,7 @@ def finish_turf(id):
387401
388402
389403@app .route ("/door/<int:id>/" )
404+ @browser_cache
390405def show_door (id : ID ):
391406 door = db .get_door_by_id (id )
392407 if door .turf_id is None :
@@ -493,6 +508,7 @@ def door_act(id: ID):
493508
494509
495510@app .route ("/voter/<int:id>/" )
511+ @browser_cache
496512def show_voter (id : ID ):
497513 voter = db .get_voter_by_id (id )
498514
@@ -581,6 +597,7 @@ def thing_title(model: Model) -> str:
581597
582598
583599@app .route ("/<typ>/<int:id>/note/" , methods = ["GET" , "POST" ])
600+ @browser_cache
584601def note_obj (typ : str , id : ID ):
585602 if typ == "turf" :
586603 restrict_turfs (id )
You can’t perform that action at this time.
0 commit comments