Replies: 20 comments 6 replies
-
I can confirm that cache control won‘t be overwritten in public folder. I dont understand |
Beta Was this translation helpful? Give feedback.
-
I'm having the same problem. I use SSG with getStaticProps. I expected the files from the public folder to have |
Beta Was this translation helpful? Give feedback.
-
I also have the same issue. Deploying on Vercel using Any workaround to this? Apparently we cannot set https://nextjs.org/docs/api-reference/next.config.js/headers#cache-control |
Beta Was this translation helpful? Give feedback.
-
This issue is a showstopper for us. We cannot update the app for our users and we have thousands who are stuck with the old cache for good. Vercel team, please, fix this issue. |
Beta Was this translation helpful? Give feedback.
-
you may want to try header configuration file the platform you use provides. one that looks like below:
vercel: https://vercel.com/docs/concepts/edge-network/headers |
Beta Was this translation helpful? Give feedback.
-
Have there been any updates/workarounds on this issue? Is there any way to overwrite the "default" non-caching behaviour of /public assets? |
Beta Was this translation helpful? Give feedback.
-
+1 |
Beta Was this translation helpful? Give feedback.
-
I'm also encountering this issue. I'm building an app that does in-browser inference on a 300mb vision transformer, and the model is being re-downloaded with every request, which makes development from a vps particularly painful. I'm indifferent towards this issue for production servers - it seems like there are other ways of configuring asset caching there - but for dev, it'd really help me to cache files in public/. |
Beta Was this translation helpful? Give feedback.
-
Is there any workaround for how to cache an asset in a public folder? I'm using next 13.5.5, and the app loads an asset (it's a Unity build), on a specific page with a 600mb on a single Unity build file, and is being re-downloaded when the page is revisited. |
Beta Was this translation helpful? Give feedback.
-
haha this is joke, right? no ability to cache public assets? |
Beta Was this translation helpful? Give feedback.
-
Has there been any updates on this? I really do not understand the logic behind having the cache max-age as 0 for public static assets. |
Beta Was this translation helpful? Give feedback.
-
Surely an option should at least be provided to opt in and set a custom cache time for the public assets (combining it with stale-while-revalidate header for the optimal result). There are perfectly reasonable use-cases where the asset should not be freshly served from the Next.js server on each page view/request. In our case, the icons take 100-300ms to load in and cause absolutely unnecessary white-space until they load in... |
Beta Was this translation helpful? Give feedback.
-
I'm having the same issue, hope there would be a solution soon! thanks |
Beta Was this translation helpful? Give feedback.
-
Am also having the same issue. Anyone have workaround for this? |
Beta Was this translation helpful? Give feedback.
-
This ensures that the Caching happens on Vercel's Edge Network (which may be seen in this case as a CDN) and not on the browser. However it would be great if we could customise this behavior further for those files that do not change at all (and could be cached on the browser) |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
This is so silly. Surely there should be a designed way to set cache control on static headers if you're just running vanilla nextjs without cf or vercel? |
Beta Was this translation helpful? Give feedback.
-
Custom SolutionI decided to host my static files on an external blob storage (like S3), configure it behind a CDN (such as CloudFront), and set up custom caching rules there. Although the initial setup was somewhat frustrating, this approach allows for modifications—such as updating images, localization files, and configuration data—without the need to redeploy the entire application. While this setup makes sense for large projects like mine, it might be an unnecessary extra cost & effort for smaller applications. |
Beta Was this translation helpful? Give feedback.
-
I tested this with Next.js 15.3.2, and it seems you can override the cache headers for files in the public folder, so this issue may no longer be valid. If you’re referencing the assets in your code and you want to have |
Beta Was this translation helpful? Give feedback.
-
This is a known limitation in Next.js. The Solutions:
To summarize: cache control for |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, we are having trouble setting custom cache behaviour for our assets in public folder, such as font files, svg and png images assets. By default we seem to get
cache-control: public, max-age=0
which differs for example from _next/static which has
cache-control: public, max-age=31536000, immutable
I would have expected assets put in public folder to have some default cache behaviour?
I've tried setting custom header in next.config.js like:
But nothing happens, at least not when testing locally. Then there is also this: https://nextjs.org/docs/api-reference/next.config.js/headers#cache-control which seems to indicate that even if I did get this to work, it would in fact not work in production?
We are using a cdn in front of our next server (not using Vercel) so we might have other ways around this, but it seems strange to me.
Beta Was this translation helpful? Give feedback.
All reactions