Skip to content

Commit c9b7cb9

Browse files
authored
Send Cache-Control header with value 'no-cache' (#204)
1 parent fd726c5 commit c9b7cb9

3 files changed

Lines changed: 4 additions & 0 deletions

File tree

NEWS.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Changelog
44
unreleased
55
----------
66

7+
* Set ``Cache-Control`` header to ```no-cache``` for served files.
8+
79
2025.08.25 - 2025-08-25
810
-----------------------
911

sphinx_autobuild/middleware.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ async def send_wrapper(message: Message) -> None:
3838
if "Content-Length" in headers:
3939
length = int(headers["Content-Length"]) + len(self.script)
4040
headers["Content-Length"] = str(length)
41+
headers["Cache-Control"] = "no-cache"
4142
elif message["type"] == "http.response.body":
4243
request_complete = not message.get("more_body", False)
4344
if add_script and request_complete:

tests/test_application.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ def test_application(tmp_path):
3333

3434
response = client.get("/")
3535
assert response.status_code == 200
36+
assert response.headers["Cache-Control"] == "no-cache"

0 commit comments

Comments
 (0)