Next.js Discord

Discord Forum

NextJS Image caching problem

Answered
Idra posted this in #help-forum
Open in Discord
Hello everyone!
I discovered a bug/problem about nextjs image caching. Basically, if i replace an image keeping the same name as the old image, the website won't recognize the file change, as a result, nextjs will show (even i re-build the whole website and delete the .next folder) the same old image.

I Didn't know about this bug/problem until now, if someone can please help me replacing an image updating it in the website, without changing its name it would be really helpful, thanks in advance!
Answered by Idra
Alright, problem solved.
Basically, it's a browser cache problem, even if you reset the cookies, you'll need to wait for the correct images to get shown.
View full answer

4 Replies

English Lop
https://nextjs.org/docs/pages/api-reference/components/image#caching-behavior <-- here's the default cachin strategy of the next/image component
English Lop
The browser is caching this request. Have you cleared your browser cache? You can do this by opening developer tools (Inspect) --> Network and look for disable cache. Refresh the page.
Alright, problem solved.
Basically, it's a browser cache problem, even if you reset the cookies, you'll need to wait for the correct images to get shown.
Answer