Replies: 1 comment 5 replies
-
Currently, it is possible to generatethe same export default defineNitroConfig({
publicAssets: [
{
baseURL: "_nuxt",
// autoHeaders: true, // (proposal below)
},
],
routeRules: {
"/_nuxt/**": {
headers: {
"cache-control": "public, max-age=0, must-revalidate",
},
},
},
}); Since these kinds of headers are also related to the frontend build (nuxt/vite), Nitro itself cannot directly modify behavior without any hints. I think we can introduce
Nuxt can itself today also achieve behavior above without involving Nitro but this would allow it to avoid having vendor-specific logic and let nitro smartly decide about dirs. (and enables same benefit for all other frameworks based on nitro for netlify preset) We might also enable |
Beta Was this translation helpful? Give feedback.
-
As stated in many discussions in netlify forums (https://answers.netlify.com/t/support-guide-why-do-i-see-uncaught-syntaxerror-unexpected-token-errors-how-can-i-use-chunking-or-versioning-for-my-assets-at-netlify/124 for example), netlify handles cache busting on assets on it's own via the ETAG/if-none-match headers combo.
Meaning it will respond with a 304 or a 200 with the new asset based on the hash sent.
Although build-time-assets-cache-busting via build hash in the filename works most of the times, it becomes a kind of a problem with lazy components/dynamic imports. This, in nuxt, is already handled via the chunk-error plugin that reloads the application whenever a chunk error appears.
But: respecting netlify proposal for the assets cache handling seems a more sane approach to me (especially when a website has a high "build-rate" e.g. 4/5 builds a day)
We found that removing hash in filenames via vite:
and changing nitro's default headers via netlify.toml
worked best in our case.
I'm keen to know what would be the best approach going forward for the netlify preset.
@pi0 @serhalp
Beta Was this translation helpful? Give feedback.
All reactions