Skip to content

Add version to static files in production#1513

Merged
jochenklar merged 2 commits into2.5.0/releasefrom
2.5.0/custom-static
Feb 5, 2026
Merged

Add version to static files in production#1513
jochenklar merged 2 commits into2.5.0/releasefrom
2.5.0/custom-static

Conversation

@jochenklar
Copy link
Member

This PR overwrites the regular Django static template tag to add the current RDMO version (if DEBUG = False). The result is that clients will drop the cached files when the version changes (aka. cache busting). There are some remarks around to not use query params for this (pointing to https://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/), but I don't think this is relevant for us.

We might to switch to [whitenoise}(https://whitenoise.readthedocs.io/en/latest/) at some point, but we need to fix our JS and CSS pipeline first and get rid of compressor.

@jochenklar jochenklar requested a review from MyPyDavid January 16, 2026 12:29
@jochenklar jochenklar self-assigned this Jan 16, 2026
@jochenklar jochenklar added this to the RDMO 2.5.0 milestone Jan 16, 2026
@jochenklar
Copy link
Member Author

It is actually a bad idea to override the template tag. There are custom storage classes for this. ManifestStaticFilesStorage would also be an idea, but would also have the same issues as whitenoise.

def url(self, name):
url = super().url(name)

if settings.DEBUG:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't have a if settings.DEBUG check anywhere in rdmo yet, should this not go in the rdmo-app?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I think its fine. settings.DEBUG is pretty low-level django. So far we did not need it.

@jochenklar jochenklar changed the title Overwrite static tag to include version Add version to static files in production Jan 20, 2026
@jochenklar
Copy link
Member Author

When running locally, __version__ is only updated when rdmo is installed not when the repo changes (I tested by creating a tag). Therefore it makes no sense to use it in development, so we will the settings.DEBUG check.

@jochenklar jochenklar merged commit b3e5549 into 2.5.0/release Feb 5, 2026
28 of 30 checks passed
@jochenklar jochenklar deleted the 2.5.0/custom-static branch February 5, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants