resolve http caching inconsistencies
This commit is contained in:
parent
1086e95036
commit
9f13218c30
1 changed files with 8 additions and 12 deletions
|
|
@ -55,24 +55,18 @@ pub(crate) fn new_router(app: App) -> Router<()> {
|
|||
ServiceBuilder::new()
|
||||
.layer(SetResponseHeaderLayer::if_not_present(
|
||||
CACHE_CONTROL,
|
||||
HeaderValue::from_static(if cfg!(debug_assertions) {
|
||||
// Disable caching when developing locally.
|
||||
"no-cache"
|
||||
} else {
|
||||
"max-age=120, stale-while-revalidate=86400"
|
||||
}),
|
||||
// JS entrypoints should always be served from the current
|
||||
// version.
|
||||
HeaderValue::from_static("no-cache"),
|
||||
))
|
||||
.service(
|
||||
ServeDir::new("js_dist").not_found_service(
|
||||
ServiceBuilder::new()
|
||||
.layer(SetResponseHeaderLayer::if_not_present(
|
||||
CACHE_CONTROL,
|
||||
HeaderValue::from_static(if cfg!(debug_assertions) {
|
||||
// Disable caching when developing locally.
|
||||
"no-cache"
|
||||
} else {
|
||||
"max-age=120, stale-while-revalidate=86400"
|
||||
}),
|
||||
// Do not allow caching of paths if they return
|
||||
// a 404 error.
|
||||
HeaderValue::from_static("no-cache"),
|
||||
))
|
||||
.service(ServeFile::new("static/_404.html")),
|
||||
),
|
||||
|
|
@ -95,6 +89,8 @@ pub(crate) fn new_router(app: App) -> Router<()> {
|
|||
ServiceBuilder::new()
|
||||
.layer(SetResponseHeaderLayer::if_not_present(
|
||||
CACHE_CONTROL,
|
||||
// Do not allow caching of paths if they return
|
||||
// a 404 error.
|
||||
HeaderValue::from_static("no-cache"),
|
||||
))
|
||||
.service(ServeFile::new("static/_404.html")),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue