From 84f26c9319c9ea366f0cd394d6feeed0db479e27 Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Sat, 8 Oct 2022 22:40:28 +0000 Subject: [PATCH] Allow basic cache-busting for major frontend version upgrades. --- bemani/frontend/app.py | 7 ++++ bemani/frontend/templates/base.html | 50 ++++++++++++++-------------- bemani/frontend/templates/react.html | 2 +- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/bemani/frontend/app.py b/bemani/frontend/app.py index b962ee2..d568e83 100644 --- a/bemani/frontend/app.py +++ b/bemani/frontend/app.py @@ -21,6 +21,10 @@ app = Flask( config = Config() +# Allow cache-busting of entire frontend for major changes such as react upgrades. +FRONTEND_CACHE_BUST: str = "site.1.0.react.16.14" + + @app.before_request def before_request() -> None: global config @@ -291,6 +295,7 @@ def navigation() -> Dict[str, Any]: 'components': components, 'any': jinja2_any, 'theme_url': jinja2_theme, + 'cache_bust': f"v={FRONTEND_CACHE_BUST}", } except AttributeError: # If we are trying to render a 500 error and we couldn't even run the @@ -300,6 +305,7 @@ def navigation() -> Dict[str, Any]: 'components': components, 'any': jinja2_any, 'theme_url': jinja2_theme, + 'cache_bust': f"v={FRONTEND_CACHE_BUST}", } pages: List[Dict[str, Any]] = [] @@ -811,4 +817,5 @@ def navigation() -> Dict[str, Any]: 'components': components, 'any': jinja2_any, 'theme_url': jinja2_theme, + 'cache_bust': f"v={FRONTEND_CACHE_BUST}", } diff --git a/bemani/frontend/templates/base.html b/bemani/frontend/templates/base.html index fd044a7..a31a83f 100644 --- a/bemani/frontend/templates/base.html +++ b/bemani/frontend/templates/base.html @@ -4,33 +4,33 @@ {% if title %} {{ title }} {% endif %} - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + {% for entry in components %} - + {% endfor %} {% block scripts %}{% endblock %} diff --git a/bemani/frontend/templates/react.html b/bemani/frontend/templates/react.html index dd594f0..03b66d7 100644 --- a/bemani/frontend/templates/react.html +++ b/bemani/frontend/templates/react.html @@ -1,6 +1,6 @@ {% extends "base.html" %} {% block scripts %} - + {% endblock %} {% block content %}