File tree 5 files changed +19
-1
lines changed
5 files changed +19
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @gradio/app " : patch
3
+ " @gradio/client " : patch
4
+ " gradio " : patch
5
+ ---
6
+
7
+ feat: Cache break themes on change
Original file line number Diff line number Diff line change @@ -173,6 +173,7 @@ export interface Config {
173
173
path : string ;
174
174
protocol : "sse_v3" | "sse_v2.1" | "sse_v2" | "sse_v1" | "sse" | "ws" ;
175
175
max_file_size ?: number ;
176
+ theme_hash ?: number ;
176
177
}
177
178
178
179
// todo: DRY up types
Original file line number Diff line number Diff line change @@ -38,4 +38,5 @@ export interface Config {
38
38
show_error : boolean ;
39
39
is_space : boolean ;
40
40
protocol : "ws" | "sse" | "sse_v1" | "sse_v2" | "sse_v2.1" | "sse_v3" ;
41
+ theme_hash ?: number ;
41
42
}
Original file line number Diff line number Diff line change @@ -988,6 +988,10 @@ def __init__(
988
988
self .theme : Theme = theme
989
989
self .theme_css = theme ._get_theme_css ()
990
990
self .stylesheets = theme ._stylesheets
991
+ theme_hasher = hashlib .sha256 ()
992
+ theme_hasher .update (self .theme_css .encode ("utf-8" ))
993
+ self .theme_hash = theme_hasher .hexdigest ()
994
+
991
995
self .encrypt = False
992
996
self .share = False
993
997
self .enable_queue = True
@@ -2040,6 +2044,7 @@ def get_config_file(self):
2040
2044
),
2041
2045
},
2042
2046
"fill_height" : self .fill_height ,
2047
+ "theme_hash" : self .theme_hash ,
2043
2048
}
2044
2049
config .update (self .default_config .get_config ())
2045
2050
config ["connect_heartbeat" ] = utils .connect_heartbeat (
Original file line number Diff line number Diff line change 29
29
path: string ;
30
30
app_id? : string ;
31
31
fill_height? : boolean ;
32
+ theme_hash? : number ;
32
33
}
33
34
34
35
let id = - 1 ;
131
132
css_text_stylesheet || undefined
132
133
);
133
134
}
134
- await mount_css (config .root + " /theme.css" , document .head );
135
+ await mount_css (
136
+ config .root + " /theme.css?v=" + config .theme_hash ,
137
+ document .head
138
+ );
135
139
if (! config .stylesheets ) return ;
136
140
137
141
await Promise .all (
You can’t perform that action at this time.
0 commit comments