Vite 4.0 cache directory retention limits
0 reputation · 15 Feb 2022, 13:01 UTC
Cache retention behavior in Vite 4.0
Vite stores compiled module artifacts under node_modules/.vite to accelerate subsequent dev‑server starts. The cache is keyed by the project’s Vite configuration, the Vite version, and a hash of each module’s source. When the dev server restarts, Vite scans the cache and rebuilds only modules whose source hash has changed.
However, the cache is never automatically pruned. After a long period of inactivity, unused entries can accumulate, consuming disk space and potentially leading to cache corruption if node_modules is modified outside Vite. The current design does not expose a configuration option to clean or prune stale entries, nor does it define a time‑based threshold for determining staleness.
Given these constraints, the following questions remain unresolved:
- Does Vite 4.0 provide any mechanism to automatically prune unused cache entries after a defined period of inactivity?
- What criteria would Vite use to determine that a cache entry is stale, and can this threshold be configured?
- How does the absence of automatic pruning affect build performance in large projects over time?