If your Vue app keeps showing old content, styles, or JavaScript after an update, the problem may be cached files—but there is no single “Vue cache” to clear. Vue applications can be affected by browser caching, a development server’s dependency cache, a production build, or a service worker. The right fix depends on where the stale version is coming from.
This guide explains how to clear Vue cache in Vue 3 and Vue 2 projects, including apps built with Vite or Vue CLI. It also covers when to clear browser data, how to refresh a production deployment, and what to avoid deleting.
Does Vue Have a Cache You Can Clear?
Vue does not provide one central cache-clearing command for an entire application. Instead, several tools and browser features may cache different parts of a Vue site. For example, Vite can cache optimized dependencies during development, a browser can keep downloaded JavaScript files, and a service worker can serve an older version of a deployed app.
Vue also has features that can preserve component instances or reuse calculated values while an app is running. These are usually working as designed, rather than indicating that files need to be cleared. Identifying the type of cache involved helps you fix the issue without removing useful project files.
Quickest Ways to Clear Vue Cache
Try these steps in order. After each one, reload the app and check whether the problem is fixed.
- Hard-refresh the page in your browser to request fresh files.
- Stop and restart the Vue development server.
- Clear the relevant Vite or Vue CLI cache.
- Remove and rebuild the production output, usually the
distfolder. - Unregister or update a service worker if the app uses one.
- Clear the browser’s site data only if the earlier steps do not work.
A full browser-cache wipe or reinstall of every dependency is rarely the best first step. Start with the cache closest to the files you changed.
Clear Vue Cache in a Vite Project
Vite is the default build tool for many modern Vue projects. During development, it optimizes dependencies and stores cached files, commonly in node_modules/.vite. If the dev server continues to serve stale dependency output, stop it and start it again with Vite’s force option:
npm run dev -- --force
The extra -- passes the option through npm to the Vite command. If you use another package manager, the equivalent commands are typically:
yarn dev --forcepnpm dev --force
You can also stop the server and remove Vite’s optimized-dependency cache manually. From the project root, delete node_modules/.vite, then run the development command again. Vite will recreate the folder as needed. If your project uses a custom cache directory, check its Vite configuration before deleting files.
For a production build that appears out of date, remove the old build output and rebuild:
rm -rf dist
npm run build
The first command is for macOS and Linux. On Windows PowerShell, use Remove-Item -Recurse -Force dist. Removing dist does not clear the browser’s copy of a previously deployed site; it only removes local build output.
Clear Vue CLI Cache
Older Vue projects may use Vue CLI, which is built on webpack. Vue CLI provides a command to clear its project cache:
npx vue-cli-service clean
Run this command from the project folder. It removes generated cache and build files managed by the Vue CLI service. Then restart the development server or create a fresh production build:
npm run serve
npm run build
If the clean command is unavailable in your project’s Vue CLI version, stop the server and remove the relevant generated cache folder. Common locations include node_modules/.cache and the project’s dist directory. Check your configuration and scripts first: custom webpack settings can change where generated files are stored.
Clear Your Browser Cache for a Vue App
If the app works locally but users still see old content after deployment, the browser may be reusing saved files. First try a hard refresh. On Windows or Linux, press Ctrl + Shift + R in many browsers. On macOS, try Cmd + Shift + R. The exact shortcut can vary by browser.
To clear data for just one site, open the browser’s developer tools, find the storage or application panel, and clear that site’s data. You can also use the browser’s site settings to remove its cached files and stored data. Be aware that clearing all site data may sign you out and remove local settings or other saved information.
In Chrome-based browsers, you can open developer tools, right-click or long-press the reload button, and choose an option such as “Empty Cache and Hard Reload.” This is useful for testing a deployment without clearing data for every website.
Hard refreshes are helpful for diagnosis, but they are not a durable fix if your deployment is sending incorrect caching headers or reusing asset filenames. For a lasting solution, use unique filenames for updated assets and configure the web server or CDN to serve the latest HTML document.
Check for a Service Worker
A service worker can store files and return them when someone revisits a site, sometimes even when the network has newer content. This behavior is common in progressive web apps and projects configured with offline support. If only some users see an old Vue app, a service worker is worth checking.
Open your browser’s developer tools and look for the service worker controls in the Application panel or equivalent. You can inspect whether a worker is registered, unregister it temporarily for testing, and clear the site’s stored data. Then reload the page. If the updated app appears, review the service worker’s update strategy and cache-versioning logic before re-enabling it.
For a deployed app, make sure the service worker is designed to install an updated version and replace old cached files. A worker that never updates its cache can keep serving stale assets even when your server has a fresh build. Test this process in a production-like environment, because development mode may behave differently.
Clear npm or Package Manager Cache Only When Needed
The npm cache stores downloaded package data. It is not the same as the Vue app’s browser cache or Vite cache, and clearing it usually will not fix a page that displays old content. Use npm’s cache verification command if you suspect a corrupted package download:
npm cache verify
As a troubleshooting measure, you can run npm cache clean --force, but this is rarely necessary. It may cause packages to be downloaded again and does not remove your project’s dependencies. If a dependency installation is genuinely corrupted, you may need to reinstall packages, but avoid deleting your lockfile as a routine cache-clearing step.
Removing node_modules and reinstalling dependencies can help with certain broken installations, but it is a more disruptive step. Keep package-lock.json, yarn.lock, or pnpm-lock.yaml so the project can install the intended dependency versions.
When Vue Behavior Looks Like a Cache
Not every stale-looking screen is caused by a file cache. Vue’s computed properties cache their result until their reactive dependencies change. That is normal behavior and generally improves performance. If a computed value is not updating, check whether it depends on the reactive state you expect and whether that state is being changed correctly.
The <KeepAlive> component can preserve inactive component instances. This lets Vue reuse a component instead of destroying and recreating it, so its local state may remain when you navigate away and back. If the component should refresh, update its state or lifecycle logic, adjust the KeepAlive configuration, or change its key where appropriate. Clearing browser files will not reset a live component instance.
Similarly, data stored in local storage, session storage, IndexedDB, or a state-management library may survive a page refresh. If an old value keeps returning, inspect where the app saves and restores that data. Remove only the specific stored item you need to reset, rather than clearing all browser data by default.
Prevent Vue Cache Problems After Deployment
Preventing stale files is more reliable than asking every visitor to clear their cache. Most Vue build tools generate hashed filenames for JavaScript and CSS assets. When the contents change, the filename changes too, allowing browsers and CDNs to cache those assets safely for longer.
The HTML document is different: it points to the current asset filenames. Configure your server to revalidate or avoid long-term caching for the HTML entry point, while allowing hashed assets to be cached for an extended period. If a CDN sits in front of the app, purge the relevant HTML or deployment paths when necessary.
- Deploy the complete build output, not just selected files.
- Confirm that the new HTML references the current hashed assets.
- Use appropriate cache headers for HTML and static assets.
- Invalidate CDN content when your hosting setup requires it.
- Test service-worker updates if your app supports offline use.
- Check for old builds on multiple devices or in a private browser window.
Conclusion
To clear Vue cache, first determine which layer is serving the outdated content. Force-restart Vite or remove its dependency cache for a development issue; use Vue CLI’s clean command for a Vue CLI project; rebuild dist for stale local output; and hard-refresh the browser or inspect the service worker for an outdated deployed site.
Vue does not have one universal cache, and deleting npm data or reinstalling every dependency is usually unnecessary. Clear the narrowest relevant cache, verify the result, and improve asset naming and caching rules if the issue returns after deployment.
Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.