Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

fix: use no-store cache headers to prevent stale frontend chunks (#12911)

Christian Byrnee0982a7174a9
diff --git a/middleware/cache_middleware.py b/middleware/cache_middleware.py
index f02135369..7a18821b0 100644
--- a/middleware/cache_middleware.py
+++ b/middleware/cache_middleware.py
@@ -32,7 +32,7 @@ async def cache_control(
)
if request.path.endswith(".js") or request.path.endswith(".css") or is_entry_point:
- response.headers.setdefault("Cache-Control", "no-cache")
+ response.headers.setdefault("Cache-Control", "no-store")
return response
# Early return for non-image files - no cache headers needed
diff --git a/server.py b/server.py
index 76904ebc9..85a8964be 100644
--- a/server.py
+++ b/server.py
@@ -310,7 +310,7 @@ class PromptServer():
@routes.get("/")
async def get_root(request):
response = web.FileResponse(os.path.join(self.web_root, "index.html"))
- response.headers['Cache-Control'] = 'no-cache'
+ response.headers['Cache-Control'] = 'no-store, must-revalidate'
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "0"
return response
diff --git a/tests-unit/server_test/test_cache_control.py b/tests-unit/server_test/test_cache_control.py
index fa68d9408..1d0366387 100644
--- a/tests-unit/server_test/test_cache_control.py
+++ b/tests-unit/server_test/test_cache_control.py
@@ -28,31 +28,31 @@ CACHE_SCENARIOS = [
},
# JavaScript/CSS scenarios
{
- "name": "js_no_cache",
+ "name": "js_no_store",
"path": "/script.js",
"status": 200,
- "expected_cache": "no-cache",
+ "expected_cache": "no-store",
"should_have_header": True,
},
{
- "name": "css_no_cache",
+ "name": "css_no_store",
"path": "/styles.css",
"status": 200,
- "expected_cache": "no-cache",
+ "expected_cache": "no-store",
"should_have_header": True,
},
{
- "name": "index_json_no_cache",
+ "name": "index_json_no_store",
"path": "/api/index.json",
"status": 200,
- "expected_cache": "no-cache",
+ "expected_cache": "no-store",
"should_have_header": True,
},
{
- "name": "localized_index_json_no_cache",
+ "name": "localized_index_json_no_store",
"path": "/templates/index.zh.json",
"status": 200,
- "expected_cache": "no-cache",
+ "expected_cache": "no-store",
"should_have_header": True,
},
# Non-matching files