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()
|
ServiceBuilder::new()
|
||||||
.layer(SetResponseHeaderLayer::if_not_present(
|
.layer(SetResponseHeaderLayer::if_not_present(
|
||||||
CACHE_CONTROL,
|
CACHE_CONTROL,
|
||||||
HeaderValue::from_static(if cfg!(debug_assertions) {
|
// JS entrypoints should always be served from the current
|
||||||
// Disable caching when developing locally.
|
// version.
|
||||||
"no-cache"
|
HeaderValue::from_static("no-cache"),
|
||||||
} else {
|
|
||||||
"max-age=120, stale-while-revalidate=86400"
|
|
||||||
}),
|
|
||||||
))
|
))
|
||||||
.service(
|
.service(
|
||||||
ServeDir::new("js_dist").not_found_service(
|
ServeDir::new("js_dist").not_found_service(
|
||||||
ServiceBuilder::new()
|
ServiceBuilder::new()
|
||||||
.layer(SetResponseHeaderLayer::if_not_present(
|
.layer(SetResponseHeaderLayer::if_not_present(
|
||||||
CACHE_CONTROL,
|
CACHE_CONTROL,
|
||||||
HeaderValue::from_static(if cfg!(debug_assertions) {
|
// Do not allow caching of paths if they return
|
||||||
// Disable caching when developing locally.
|
// a 404 error.
|
||||||
"no-cache"
|
HeaderValue::from_static("no-cache"),
|
||||||
} else {
|
|
||||||
"max-age=120, stale-while-revalidate=86400"
|
|
||||||
}),
|
|
||||||
))
|
))
|
||||||
.service(ServeFile::new("static/_404.html")),
|
.service(ServeFile::new("static/_404.html")),
|
||||||
),
|
),
|
||||||
|
|
@ -95,6 +89,8 @@ pub(crate) fn new_router(app: App) -> Router<()> {
|
||||||
ServiceBuilder::new()
|
ServiceBuilder::new()
|
||||||
.layer(SetResponseHeaderLayer::if_not_present(
|
.layer(SetResponseHeaderLayer::if_not_present(
|
||||||
CACHE_CONTROL,
|
CACHE_CONTROL,
|
||||||
|
// Do not allow caching of paths if they return
|
||||||
|
// a 404 error.
|
||||||
HeaderValue::from_static("no-cache"),
|
HeaderValue::from_static("no-cache"),
|
||||||
))
|
))
|
||||||
.service(ServeFile::new("static/_404.html")),
|
.service(ServeFile::new("static/_404.html")),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue