How to set cache-control on Files response #584
Answered
by
danieldickison
danieldickison
asked this question in
Q&A
-
I apologize if this is something basic that I'm missing, but say I want to set a Thanks for any pointers! |
Beta Was this translation helpful? Give feedback.
Answered by
danieldickison
Nov 16, 2022
Replies: 1 comment
-
I think I figured this out, which is to use .service(
web::scope("/static")
.wrap(middleware::DefaultHeaders::new().add(("Cache-Control", "max-age=86400")))
.service(Files::new("/", &config.static_path).prefer_utf8(true)),
) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
danieldickison
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think I figured this out, which is to use
web::scope
for the static Files service, and adding aDefaultHeaders
middleware just for that scope: