Rocket icon indicating copy to clipboard operation
Rocket copied to clipboard

Caching a background image with the `Cache-Control` header

Open nonk123 opened this issue 8 months ago • 0 comments

Sounds simple enough: return a NamedFile from a handler whlist setting the Cache-Control header to e.g. max-age=86400. Still, I can't seem to figure this out no matter how much I look into the docs.

I'm using rocket 0.5.1 if that matters.

My questions:

  • Is there no built-in way to "just do" this? Setting a caching policy for an image must be a common operation, especially for FileServer and alike.
  • Do I really need to implement a custom Responder whenever I need to add/change a response header? It's the closest I've actually gotten to solving this, but it never worked in the end since it needed async in order to respond from a NamedFile.

nonk123 avatar Jun 27 '24 13:06 nonk123