diff --git a/services/api-server/src/api_server/main.py b/services/api-server/src/api_server/main.py index 226866d..91907a6 100644 --- a/services/api-server/src/api_server/main.py +++ b/services/api-server/src/api_server/main.py @@ -8442,7 +8442,11 @@ def _html5_sse_headers() -> dict[str, str]: def _html5_response(fragment: str) -> Response: - return Response(fragment, media_type="text/html; charset=utf-8") + return Response( + fragment, + media_type="text/html; charset=utf-8", + headers={"Cache-Control": "no-cache, no-transform"}, + ) def _html5_sse_response(content: Any) -> StreamingResponse: diff --git a/services/api-server/tests/test_api.py b/services/api-server/tests/test_api.py index ce9235a..98aabd0 100644 --- a/services/api-server/tests/test_api.py +++ b/services/api-server/tests/test_api.py @@ -44,6 +44,12 @@ def assert_html5_contract(text: str, *markers: str, full_page: bool = False) -> assert marker in text +def assert_html5_response_contract(response, *markers: str, full_page: bool = False) -> None: + assert "text/html" in response.headers["content-type"] + assert response.headers["cache-control"] == "no-cache, no-transform" + assert_html5_contract(response.text, *markers, full_page=full_page) + + def test_cors_allows_lan_panel_origin(): client = TestClient(app) response = client.options( @@ -301,7 +307,7 @@ def test_html5_contracts_are_server_rendered_and_stable(tmp_path: Path): for path, markers in full_pages: response = client.get(path) assert response.status_code == 200 - assert_html5_contract(response.text, *markers, full_page=True) + assert_html5_response_contract(response, *markers, full_page=True) partials = [ (f"/html5/projects/{project_id}/symbols", {"q": "Проверить"}, ("data-html5-symbol",)), @@ -316,7 +322,7 @@ def test_html5_contracts_are_server_rendered_and_stable(tmp_path: Path): for path, params, markers in partials: response = client.get(path, params=params) assert response.status_code == 200 - assert_html5_contract(response.text, *markers) + assert_html5_response_contract(response, *markers) def test_html5_project_index_creates_project_with_fragment():