diff --git a/phono-server/src/routes/mod.rs b/phono-server/src/routes/mod.rs index 8e860bd..04c235c 100644 --- a/phono-server/src/routes/mod.rs +++ b/phono-server/src/routes/mod.rs @@ -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")),