Images served by next do not have cache-control set
See original GitHub issueI’ve noticed that Next does not set any cache-control
headers when serving images generated by this plugin. Given that many CDNs use these headers to determine whether or not to cache an image, it seems like this renders the point of the content hashes moot.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Custom Cache-Control response header for `/_next/image`
I had to rollback to next 10.0.1 , since this problem does not happen in that version. I cannot serve my images with...
Read more >How can I cache dynamic images in Next app? - Stack Overflow
The object contains property imageUrl, which is a link to to the image. How can I set cache-control to that image? javascript ·...
Read more >Going to Production - Next.js
Cache-Control headers set in next.config.js will be overwritten in production to ensure that static assets can be cached effectively. If you need to ......
Read more >How to set up caching for images created by Next.JS <Image/>
The images are served by Netlify Functions and headers in .toml do not apply to Functions. I believe, Next.js plugin handles caching headers ......
Read more >Image Optimization Through Next.js - Topcoder
The cache-control header's max-age value is utilized specifically. When both s-maxage and max-age are found, s-maxage is chosen.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This issue can easily be fixed without overriding the built-in server and losing its benefits. In your
next.config.js
:The ‘trick’ here is that Next.js slaps a
Cache-Control: public, max-age=31536000, immutable
header on whatever is in the.next/static/chunks
folder, which is fortunate (and appropriate). 🎉Thank you very much for this workaround @sincraianul! Yes, I will make this the default folder with the next major version.