Skip to content

Commit 77e23d1

Browse files
committed
perf(server): enable cache-control for static js and logo assets
1 parent 5bd94e9 commit 77e23d1

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/main.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ async fn pwa_logo() -> Result<Response<Body>, String> {
2626
Response::builder()
2727
.status(200)
2828
.header("content-type", "image/png")
29+
.header("Cache-Control", "public, max-age=1209600, s-maxage=86400")
2930
.body(full(include_bytes!("../static/logo.png").as_ref()))
3031
.unwrap_or_default(),
3132
)
@@ -37,6 +38,7 @@ async fn iphone_logo() -> Result<Response<Body>, String> {
3738
Response::builder()
3839
.status(200)
3940
.header("content-type", "image/png")
41+
.header("Cache-Control", "public, max-age=1209600, s-maxage=86400")
4042
.body(full(include_bytes!("../static/apple-touch-icon.png").as_ref()))
4143
.unwrap_or_default(),
4244
)
@@ -258,17 +260,17 @@ async fn main() {
258260
app.at("/opensearch.xml").get(|_| opensearch().boxed());
259261
app
260262
.at("/playHLSVideo.js")
261-
.get(|_| resource(include_str!("../static/playHLSVideo.js"), "text/javascript", false).boxed());
263+
.get(|_| resource(include_str!("../static/playHLSVideo.js"), "text/javascript", true).boxed());
262264
app
263265
.at("/hls.min.js")
264-
.get(|_| resource(include_str!("../static/hls.min.js"), "text/javascript", false).boxed());
266+
.get(|_| resource(include_str!("../static/hls.min.js"), "text/javascript", true).boxed());
265267
app
266268
.at("/highlighted.js")
267-
.get(|_| resource(include_str!("../static/highlighted.js"), "text/javascript", false).boxed());
269+
.get(|_| resource(include_str!("../static/highlighted.js"), "text/javascript", true).boxed());
268270
app
269271
.at("/check_update.js")
270-
.get(|_| resource(include_str!("../static/check_update.js"), "text/javascript", false).boxed());
271-
app.at("/copy.js").get(|_| resource(include_str!("../static/copy.js"), "text/javascript", false).boxed());
272+
.get(|_| resource(include_str!("../static/check_update.js"), "text/javascript", true).boxed());
273+
app.at("/copy.js").get(|_| resource(include_str!("../static/copy.js"), "text/javascript", true).boxed());
272274

273275
app.at("/commits.atom").get(|_| async move { proxy_commit_info().await }.boxed());
274276
app.at("/instances.json").get(|_| async move { proxy_instances().await }.boxed());

0 commit comments

Comments
 (0)