From f064f2726e1b28f6a799ee8f40d61243990863e9 Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio Date: Fri, 31 Jan 2025 14:22:46 +0100 Subject: [PATCH] Implement cache busting for our own static files --- pgcommitfest/commitfest/templates/base.html | 4 ++-- pgcommitfest/commitfest/templatetags/commitfest.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pgcommitfest/commitfest/templates/base.html b/pgcommitfest/commitfest/templates/base.html index 4a6ba990..382c43bc 100644 --- a/pgcommitfest/commitfest/templates/base.html +++ b/pgcommitfest/commitfest/templates/base.html @@ -6,7 +6,7 @@ - + {%block extrahead%}{%endblock%} {%if rss_alternate%} {%endif%} @@ -43,6 +43,6 @@

{{title}}

- + {%block morescript%}{%endblock%} diff --git a/pgcommitfest/commitfest/templatetags/commitfest.py b/pgcommitfest/commitfest/templatetags/commitfest.py index c51765d2..08ec00c0 100644 --- a/pgcommitfest/commitfest/templatetags/commitfest.py +++ b/pgcommitfest/commitfest/templatetags/commitfest.py @@ -1,5 +1,6 @@ from django.template.defaultfilters import stringfilter from django import template +from uuid import uuid4 from pgcommitfest.commitfest.models import PatchOnCommitFest @@ -43,6 +44,18 @@ def alertmap(value): return 'alert-info' +# Generate a GET parameter that's unique per startup of the python process to +# bust the cache of the client, so that it pulls in possibly updated JS/CSS +# files. +STATIC_FILE_PARAM = f"v={uuid4()}" + + +# This GET parameter should be added to every one of our static files. +@register.simple_tag +def static_file_param(): + return STATIC_FILE_PARAM + + @register.filter(name='hidemail') @stringfilter def hidemail(value):