Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions codespeed/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
HttpResponseNotFound, StreamingHttpResponse
from django.db.models import F
from django.shortcuts import get_object_or_404, render
from django.views.decorators.cache import cache_page
from django.views.decorators.http import require_GET, require_POST
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.clickjacking import xframe_options_exempt
Expand Down Expand Up @@ -112,7 +113,15 @@ def embed_comparison(request):
return render(request, 'embed_comparison.html', context)


# The historical comparison only changes when new results are saved, which
# happens at most a few times a day, yet computing it costs ~2s of database
# time per request. Cache the rendered JSON server-side and let browsers
# reuse it too.
HISTORICAL_CACHE_SECONDS = 30 * 60


@require_GET
@cache_page(HISTORICAL_CACHE_SECONDS)
def gethistoricaldata(request):
# 'labels' maps each key in tagged_revs (plus baseline and 'latest') to
# a two-line label [tag, project] for the x axis of the history chart.
Expand Down
Loading