Skip to content

Commit ed0f4a6

Browse files
dont cache new locale entry points (#10101)
1 parent 041b882 commit ed0f4a6

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

middleware/cache_middleware.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ async def cache_control(
2626
"""Cache control middleware that sets appropriate cache headers based on file type and response status"""
2727
response: web.Response = await handler(request)
2828

29-
if (
30-
request.path.endswith(".js")
31-
or request.path.endswith(".css")
32-
or request.path.endswith("index.json")
33-
):
29+
path_filename = request.path.rsplit("/", 1)[-1]
30+
is_entry_point = path_filename.startswith("index") and path_filename.endswith(
31+
".json"
32+
)
33+
34+
if request.path.endswith(".js") or request.path.endswith(".css") or is_entry_point:
3435
response.headers.setdefault("Cache-Control", "no-cache")
3536
return response
3637

tests-unit/server_test/test_cache_control.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@
4848
"expected_cache": "no-cache",
4949
"should_have_header": True,
5050
},
51+
{
52+
"name": "localized_index_json_no_cache",
53+
"path": "/templates/index.zh.json",
54+
"status": 200,
55+
"expected_cache": "no-cache",
56+
"should_have_header": True,
57+
},
5158
# Non-matching files
5259
{
5360
"name": "html_no_header",

0 commit comments

Comments
 (0)