File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -26,11 +26,12 @@ async def cache_control(
26
26
"""Cache control middleware that sets appropriate cache headers based on file type and response status"""
27
27
response : web .Response = await handler (request )
28
28
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 :
34
35
response .headers .setdefault ("Cache-Control" , "no-cache" )
35
36
return response
36
37
Original file line number Diff line number Diff line change 48
48
"expected_cache" : "no-cache" ,
49
49
"should_have_header" : True ,
50
50
},
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
+ },
51
58
# Non-matching files
52
59
{
53
60
"name" : "html_no_header" ,
You can’t perform that action at this time.
0 commit comments