Dont overwrite cache-control header in session middleware (#4337)

This commit is contained in:
Nutomic 2024-01-04 17:44:36 +01:00 committed by GitHub
parent 023c9f4fcd
commit 3cad3b2119
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 11 deletions

@ -1 +1 @@
Subproject commit 15815aea74fe97360afc03496b3ad62588649af0 Subproject commit a36865ee8ca3658fea31ba948b67b75a812e84fc

View file

@ -85,16 +85,19 @@ where
let mut res = svc.call(req).await?; let mut res = svc.call(req).await?;
// Add cache-control header. If user is authenticated, mark as private. Otherwise cache // Add cache-control header if none is present
// up to one minute. if !res.headers().contains_key(CACHE_CONTROL) {
let cache_value = if jwt.is_some() { // If user is authenticated, mark as private. Otherwise cache
"private" // up to one minute.
} else { let cache_value = if jwt.is_some() {
"public, max-age=60" "private"
}; } else {
res "public, max-age=60"
.headers_mut() };
.insert(CACHE_CONTROL, HeaderValue::from_static(cache_value)); res
.headers_mut()
.insert(CACHE_CONTROL, HeaderValue::from_static(cache_value));
}
Ok(res) Ok(res)
}) })
} }