From adbaf0decb1ec2a2b042f6e8a0d8c2dc48546a8e Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 31 Oct 2025 15:43:15 +0100 Subject: [PATCH 1/2] Send Cache-Control header with value no-cache --- sphinx_autobuild/middleware.py | 1 + tests/test_application.py | 1 + 2 files changed, 2 insertions(+) diff --git a/sphinx_autobuild/middleware.py b/sphinx_autobuild/middleware.py index 2652a0c..ae12575 100644 --- a/sphinx_autobuild/middleware.py +++ b/sphinx_autobuild/middleware.py @@ -38,6 +38,7 @@ async def send_wrapper(message: Message) -> None: if "Content-Length" in headers: length = int(headers["Content-Length"]) + len(self.script) headers["Content-Length"] = str(length) + headers["Cache-Control"] = "no-cache" elif message["type"] == "http.response.body": request_complete = not message.get("more_body", False) if add_script and request_complete: diff --git a/tests/test_application.py b/tests/test_application.py index 6919d9a..e1e3be4 100644 --- a/tests/test_application.py +++ b/tests/test_application.py @@ -33,3 +33,4 @@ def test_application(tmp_path): response = client.get("/") assert response.status_code == 200 + assert response.headers["Cache-Control"] == "no-cache" From 66fb12938c9c5e983f9bec453347373ccc6448bb Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Tue, 16 Dec 2025 13:39:39 +0100 Subject: [PATCH 2/2] Update NEWS.rst. --- NEWS.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index 58ef6fb..87c4a9a 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -4,6 +4,8 @@ Changelog unreleased ---------- +* Set ``Cache-Control`` header to ```no-cache``` for served files. + 2025.08.25 - 2025-08-25 -----------------------