Idea for Galaxy: automatic image caching

I’ve used SvelteKit recently and love how it automatically caches the images to the browser and tracks the changes in a smart way. I think Galaxy can have a similar feature. For example, it can automatically drop in a bit of code like this:

import { WebApp } from 'meteor/webapp';

WebApp.rawConnectHandlers.use((req, res, next) => {
  if (/\.(jpg|jpeg|png|gif)$/.test(req.url)) {
    res.setHeader('Cache-Control', 'public, max-age=31536000'); // Cache for 1 year

And then it can add a query param to each image, or something of that nature, i.e.:

That way, the app doesn’t re-download all the static assets on every load

1 Like

I understand this only covers the /public folder but I am not sure anyone stores assets within the Meteor client bundle anymore. If they do, that is probably wrong.

Here at the bottom: Images • Docs • SvelteKit

" * Consider serving all images via CDN regardless of the image optimization types you use. CDNs reduce latency by distributing copies of static assets globally."

Galaxy has a suggestion box for ideas: