Replies: 1 comment
-
|
From my understanding, Scenario 1: Image content changes, but the URL remains the sameSuppose you have: If the image is updated on the server but the URL stays unchanged, users may continue seeing the cached version until the cache expires. For example: images: {
minimumCacheTTL: 3600, // 1 hour
}If a user visits the page, the optimized image may be cached for up to 1 hour. If the image content changes during that period, users could still receive the older cached version until the cache is refreshed. Scenario 2: Image URL changes after an updateIf the URL changes, such as: becoming or then browsers, CDNs, and Next.js treat it as a completely new resource. In this case, users will receive the updated image immediately because the cache key is different. Recommended approach for frequently updated imagesFor applications such as:
it is generally recommended to use cache-busting/versioned URLs rather than relying on a very low Examples: This allows you to:
How I usually think about
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I have a question regarding the
next/imagecomponent in the Next.js Pages Router. Although I am using Next.js 13, I assume the behavior is similar or the same in the latest version, Next.js 14.According to the official documentation for
next/imagein the Pages Router (https://nextjs.org/docs/pages/api-reference/components/image), theminimumCacheTTLproperty can be set like this:I’m curious about the criteria for determining the appropriate minimumCacheTTL value. For instance, if images in a community post or e-commerce product are updated frequently, and a user revisits the page before the cache duration expires, will they still see the old image because the cached version is still valid?
Additionally, would this be an issue only if the image URL remains the same? If the image’s URL changes after an update, does it bypass the cache and display the new image? How can I handle these scenarios efficiently?
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions