Next.js Discord

Discord Forum

Next Image 13.4 Cache - is it server side and can it be individually refreshed?

Answered
American Shorthair posted this in #help-forum
Open in Discord
American ShorthairOP
I could use some guidance around this. In my app i have user profile pictures. Those providle pictures will be served up in many different sizes through the application. I would like to use NextImage through my entire application but if the app grows large enough i'm worried about processing images every time I redeploy because that would just be too much image processing and get expensive.

So

1. Is there a way to cache the images server side so they persist through deployments indefinitely
2. If a user uploads a new image is there a way to invalidate the cache on a per image basis?

Or for this type of image would it be best to just process images myself into a permanent storage bucket in different sizes and qualities.

Any guidance would be appreciated. Thank you.
Answered by joulev
i think you have to use an external storage service here
View full answer

4 Replies

Answer
@joulev i think you have to use an external storage service here
American ShorthairOP
awesome. Just wanted to double check and make sure there wasnt some features that would allow this that I was missing. Thank you very much, i appreciate it 🙂
in the first place, when a user uploads a new image, you cannot write it to public (vercel fs is read-only, self-host then changes in public requires a new build)
so without even worrying about caching, you have to save your images somewhere else because public is read-only