File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414 HttpResponseNotFound , StreamingHttpResponse
1515from django .db .models import F
1616from django .shortcuts import get_object_or_404 , render
17+ from django .views .decorators .cache import cache_page
1718from django .views .decorators .http import require_GET , require_POST
1819from django .views .decorators .csrf import csrf_exempt
1920from django .views .decorators .clickjacking import xframe_options_exempt
@@ -112,7 +113,15 @@ def embed_comparison(request):
112113 return render (request , 'embed_comparison.html' , context )
113114
114115
116+ # The historical comparison only changes when new results are saved, which
117+ # happens at most a few times a day, yet computing it costs ~2s of database
118+ # time per request. Cache the rendered JSON server-side and let browsers
119+ # reuse it too.
120+ HISTORICAL_CACHE_SECONDS = 30 * 60
121+
122+
115123@require_GET
124+ @cache_page (HISTORICAL_CACHE_SECONDS )
116125def gethistoricaldata (request ):
117126 # 'labels' maps each key in tagged_revs (plus baseline and 'latest') to
118127 # a two-line label [tag, project] for the x axis of the history chart.
You can’t perform that action at this time.
0 commit comments