Skip to content

Commit

Permalink
chore(ui): turn on public cache for next js bundled files
Browse files Browse the repository at this point in the history
  • Loading branch information
wsxiaoys committed May 2, 2024
1 parent b71f9c5 commit 13247e2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ee/tabby-webserver/src/routes/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ where
match WebAssets::get(decoded_path.as_ref()) {
Some(content) => {
let body = Body::from(content.data);
let mime = mime_guess::from_path(path).first_or_octet_stream();
Response::builder()
.header(header::CONTENT_TYPE, mime.as_ref())
let mime = mime_guess::from_path(&path).first_or_octet_stream();
let mut builder =
Response::builder().header(header::CACHE_CONTROL, "public, max-age=604800");
if path.ends_with(".html") {
builder = builder.header(header::CONTENT_TYPE, mime.as_ref())
};
builder
.body(body)
.unwrap_or_else(|_| panic!("Invalid response"))
}
Expand Down

0 comments on commit 13247e2

Please sign in to comment.