From 8788bac95a6d94f35af2c08129d5c14961e81e49 Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Thu, 2 Apr 2026 03:36:06 +0000 Subject: [PATCH] Fix Cloudflare caching serving stale JS/CSS Root cause: Cloudflare CDN was caching old static assets, so the browser never received the updated JS with mode tab click handlers. Fix: Add cache-busting query strings (?v=) to static asset URLs, generated at container startup time. Every deploy gets a new timestamp, forcing CDN to fetch fresh files. Co-Authored-By: Claude Opus 4.6 (1M context) --- app.py | 3 +++ templates/index.html | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 3b36bf3..58ab9cd 100644 --- a/app.py +++ b/app.py @@ -1,6 +1,7 @@ """ASCII Art Generator - FastAPI Web Application.""" import tempfile +import time import os from pathlib import Path @@ -23,6 +24,7 @@ app.mount("/static", StaticFiles(directory=BASE_DIR / "static"), name="static") templates = Jinja2Templates(directory=BASE_DIR / "templates") MAX_UPLOAD_SIZE = 10 * 1024 * 1024 # 10MB +CACHE_BUST = str(int(time.time())) ALLOWED_TYPES = {"image/png", "image/jpeg", "image/gif", "image/webp", "image/bmp"} @@ -33,6 +35,7 @@ async def index(request: Request): "palettes": list(PALETTES.keys()), "palette_previews": {k: v[:12] for k, v in PALETTES.items()}, "patterns": PATTERN_TYPES, + "cache_bust": CACHE_BUST, }) diff --git a/templates/index.html b/templates/index.html index 20593ed..7fcbb59 100644 --- a/templates/index.html +++ b/templates/index.html @@ -4,7 +4,7 @@ ASCII Art Generator - + @@ -127,6 +127,6 @@

Powered by Unicode · jeffemmett.com

- +