Skip to content

How to add Cache Control to the response header of “actix_files” ? #3260

Answered by robjtede
154286 asked this question in Q&A
Discussion options

You must be logged in to vote

Here's what I'd recommend:

.service(
    actix_web::web::scope("/images")
        .default_service(
            actix_files::Files::new("", &CONFIG.images.dir).use_last_modified(true),
        )
        .wrap(DefaultHeaders::new()...),
)

It does feel natural to want to wrap the files service like this though, I should have a think about making it easier.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@154286
Comment options

Answer selected by robjtede
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants