Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cache Headers for static site #44

Merged
merged 1 commit into from
Nov 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add Cache Headers for static site
Add Cache-Control with a max age of one week. This will improve
(repeat) load performance a bit with caching. This will also help
with access over Tor.
nickfarrow committed Nov 3, 2022
commit d51af099a707ec03c519c1416c182d419bd2ece5
6 changes: 5 additions & 1 deletion src/http.rs
Original file line number Diff line number Diff line change
@@ -55,7 +55,11 @@ async fn handle_web_req(
let file =
std::fs::read(Path::new(STATIC_DIR).join(directory_traversal_vulnerable_path))
.expect("can't open static file");
Ok(Response::new(Body::from(file)))
Ok(Response::builder()
.status(200)
.header("Cache-Control", "max-age=604800")
.body(Body::from(file))
.expect("valid response"))
}

(&Method::POST, "/pj") => {