From 99b0601e06090df4dba4bcc73ca01b5f116b4a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sch=C3=A4fer?= <felix@thegcat.net> Date: Sun, 23 Jun 2019 01:29:31 +0200 Subject: [PATCH] Cache the html head --- pretix_public_registrations/signals.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pretix_public_registrations/signals.py b/pretix_public_registrations/signals.py index e19cc17..1032279 100644 --- a/pretix_public_registrations/signals.py +++ b/pretix_public_registrations/signals.py @@ -11,12 +11,16 @@ from pretix.base.models import OrderPosition @receiver(html_head, dispatch_uid="public_registrations_html_head") def add_public_registrations_html_head(sender, request=None, **kwargs): - url = resolve(request.path_info) - if "event.index" in url.url_name: - template = get_template("pretix_public_registrations/head.html") - return template.render() - else: - return "" + cached = sender.cache.get('public_registrations_html_head') + if cached is None: + url = resolve(request.path_info) + if "event.index" in url.url_name: + template = get_template("pretix_public_registrations/head.html") + cached = template.render() + else: + cached = "" + sender.cache.set('public_registrations_html_head', cached) + return cached @receiver(question_form_fields, dispatch_uid="public_registration_question") -- GitLab