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(
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
Original file line number Diff line number Diff line change 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" ,
You can’t perform that action at this time.
0 commit comments