Make cache duration customizable

This commit is contained in:
Emi Simpson 2021-10-26 16:56:06 -04:00
parent cc4f3669c5
commit 201237c3f3
Signed by: Emi
GPG key ID: A12F2C2FFDC3D847

View file

@ -4,6 +4,8 @@ use actix_web::HttpRequest;
use actix_web::web::resource;
use actix_web::Resource;
const DEFAULT_CACHE: &str = "max-age=86400";
/// Represents a single static asset
///
/// Each asset is embeded into the binary, and can be served under the
@ -32,7 +34,7 @@ impl StaticAsset {
let mut response = HttpResponse::Ok();
response
.header("Etag", env!("CARGO_PKG_VERSION"))
.header("Cache-Control", "max-age=86400");
.header("Cache-Control", DEFAULT_CACHE);
let req_etag = req.headers().get("If-None-Match");
match req_etag {