svimg icon indicating copy to clipboard operation
svimg copied to clipboard

Add cache control header

Open jasongitmail opened this issue 1 year ago • 3 comments

For images imported using Vite, SvelteKit serves them with the same far future cache header that it uses for JS and CSS assets, allowing the image to be cached by browsers and CDNs for 1yr. Example:

File: /_app/immutable/assets/logo.51dc829a.svg
Header: Cache-Control: public,max-age=31536000,immutable

However, images generated using svgimg do not have a cache control header when served :

// No cache control header.
File: static/images/g/screenshot.ad63d76.2defc3d93c320814083cab981b15c337.avif

jasongitmail avatar Jun 08 '23 20:06 jasongitmail

I would like to see this work aswell, have you found any workarounds?

ErikSandquist avatar Dec 25 '23 15:12 ErikSandquist

@ErikSandquist SvelteKit now has built in image support. Better to transition over to that, imo. It builds the images Vite and adds hashes to the file names, so you can cache them well.

jasongitmail avatar Dec 25 '23 21:12 jasongitmail

@jasongitmail Thanks for the info. Will check it out!

ErikSandquist avatar Dec 25 '23 21:12 ErikSandquist