Skip to content

Implement cache busting for our own static files #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions pgcommitfest/commitfest/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<link rel="stylesheet" href="/media/commitfest/css/jquery-ui.css" type="text/css">
<link rel="stylesheet" href="/media/commitfest/css/bootstrap.css" />
<link rel="stylesheet" href="/media/commitfest/css/bootstrap-theme.min.css" />
<link rel="stylesheet" href="/media/commitfest/css/commitfest.css" />
<link rel="stylesheet" href="/media/commitfest/css/commitfest.css?{% static_file_param %}" />
<link rel="shortcut icon" href="/media/commitfest/favicon.ico" />
{%block extrahead%}{%endblock%}
{%if rss_alternate%} <link rel="alternate" type="application/rss+xml" title="{{rss_alternate_title}}" href="{{rss_alternate}}" />{%endif%}
Expand Down Expand Up @@ -43,6 +43,6 @@ <h1>{{title}}</h1>
<script src="/media/commitfest/js/jquery.js"></script>
<script src="/media/commitfest/js/jquery-ui.js"></script>
<script src="/media/commitfest/js/bootstrap.js"></script>
<script src="/media/commitfest/js/commitfest.js"></script>
<script src="/media/commitfest/js/commitfest.js?{% static_file_param %}"></script>
{%block morescript%}{%endblock%}
</html>
13 changes: 13 additions & 0 deletions pgcommitfest/commitfest/templatetags/commitfest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.template.defaultfilters import stringfilter
from django import template
from uuid import uuid4

from pgcommitfest.commitfest.models import PatchOnCommitFest

Expand Down Expand Up @@ -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):
Expand Down