dont cache new locale entry points

This commit is contained in:
bymyself 2025-09-29 12:01:49 -07:00
parent b60dc31627
commit 67a8d2e317
2 changed files with 13 additions and 5 deletions

View File

@ -26,11 +26,12 @@ async def cache_control(
"""Cache control middleware that sets appropriate cache headers based on file type and response status""" """Cache control middleware that sets appropriate cache headers based on file type and response status"""
response: web.Response = await handler(request) response: web.Response = await handler(request)
if ( path_filename = request.path.rsplit("/", 1)[-1]
request.path.endswith(".js") is_entry_point = path_filename.startswith("index") and path_filename.endswith(
or request.path.endswith(".css") ".json"
or request.path.endswith("index.json") )
):
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-cache")
return response return response

View File

@ -48,6 +48,13 @@ CACHE_SCENARIOS = [
"expected_cache": "no-cache", "expected_cache": "no-cache",
"should_have_header": True, "should_have_header": True,
}, },
{
"name": "localized_index_json_no_cache",
"path": "/templates/index.zh.json",
"status": 200,
"expected_cache": "no-cache",
"should_have_header": True,
},
# Non-matching files # Non-matching files
{ {
"name": "html_no_header", "name": "html_no_header",