NuxtJS not update after deploy on production server
I have experience after build nuxt with command npm run build on production server sometimes need to open network devtool network and disabled cache then reload so my webiste is change, is there better way to detect the new version of build to when it change will automatic pull the new build form server
2 Replies
Hi @silvesterwali. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
When deploying a new build of your Nuxt application to production, users may sometimes see cached (old) content until they manually clear their browser cache or disable caching in devtools. This is a common issue, especially with static assets or statically generated pages.
From the knowledge sources, there is no official, built-in Nuxt feature that automatically detects a new build and forces clients to fetch the latest version. However, here are some relevant points and partial solutions:
- If you are using static site generation or long cache durations (e.g., via route rules), you may need to implement a cache-busting strategy or a mechanism to notify clients of a new version. There is a feature request and discussion about regenerating cache on demand (e.g., via a query string like ?regenerate=true), but this is not a standard feature yet. There is mention of a preview mode for on-demand regeneration, but it is not a full solution for production cache invalidation for all users Regenerate cache through a url query string.
- If you are serving your app with SSR or as a Node server, deploying a new build and restarting the server should serve the latest content. However, browser and CDN caches may still serve old assets unless you use cache-busting techniques (like hashed filenames for assets, which Nuxt does by default for static assets).
- If you are using a CDN or proxy (like Cloudflare), ensure that your cache settings are not too aggressive, or configure cache purging on deploy.
- There is no mention in the sources of a built-in Nuxt mechanism to notify clients of a new build and force a reload. This kind of functionality (e.g., a service worker or polling endpoint to check for a new version) would need to be implemented manually.
In summary:
Nuxt does not provide an out-of-the-box solution to automatically detect and pull a new build for users when you deploy. You will need to implement cache-busting strategies or a custom notification mechanism if you want users to always get the latest version without manual cache clearing. The knowledge sources do not contain a ready-made solution for this scenario. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
Nuxt does not provide an out-of-the-box solution to automatically detect and pull a new build for users when you deploy. You will need to implement cache-busting strategies or a custom notification mechanism if you want users to always get the latest version without manual cache clearing. The knowledge sources do not contain a ready-made solution for this scenario. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
<@641559666782109698> Kapa.ai is still learning and improving, please let me know how I did by reacting below.