fix(ui): stop the pages being cached, and the labels duplicating
Firefox served a cached copy of the brewing page after the advice became a button and a pop-out, so the phone kept showing the old inline advice - a long paragraph in the table cell, with the button label reading "Read the adviceAdvice". Two separate causes: The pages had no cache headers, so Firefox was free to reuse them. They now send Cache-Control: no-store, must-revalidate. The rule that hides the short label was scoped to `table.data .short`, so it did not apply to the advice button's label. A stale stylesheet then showed both forms at once. The rule is now on `.short` alone, so it applies wherever the pattern is used - a table heading, the advice button, the Active Beers page - and only ever one form can show. Verified at 390px and 1280px: the phone shows "Advice", the desktop shows "Read the advice" and "BREWING ADVICE", and no element ever shows both. 192 tests pass.
This commit is contained in:
@@ -87,6 +87,18 @@ def create_app(config: dict | None = None) -> Flask:
|
||||
if config:
|
||||
app.config.update(config)
|
||||
|
||||
# The pages must not be cached by the browser.
|
||||
|
||||
# A phone held on to a cached copy of the brewing page and showed
|
||||
# the old inline advice instead of the button and the pop-out, so
|
||||
# the change was not visible until the cache was cleared by hand.
|
||||
@app.after_request
|
||||
def _no_store(response):
|
||||
if response.mimetype == "text/html":
|
||||
response.headers["Cache-Control"] = "no-store, must-revalidate"
|
||||
response.headers["Pragma"] = "no-cache"
|
||||
return response
|
||||
|
||||
csrf = CSRFProtect(app)
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
Reference in New Issue
Block a user