In Nx 21, the legacy file system cache will be removed in favor of a new database cache. The new database cache stores metadata in a database, rather than blindly trusting the file system. The database cache has the following benefits:
- Cache reads and writes are faster.
- The local cache is more secure since Nx will no longer retrieve artifacts it does not recognize.
The legacy file system cache can still be used in Nx 20 by setting useLegacyCache: true in your nx.json file. To gain the benefits above, remove useLegacyCache: true from your nx.json.
If you are currently using a custom task runner or the NX_REJECT_UNKNOWN_LOCAL_CACHE environment variable continue reading below.
tasksRunnerOptions
Section titled “tasksRunnerOptions”As of Nx 20, the tasksRunnerOptions property in nx.json is deprecated. This property was used to register custom task runners. tasksRunnerOptions and custom task runners will not work with the new database cache.
If you are using a custom tasks runner to customize your cache, you have the following options:
Use Nx Cloud for your remote cache. This is the safest, lowest-maintenance, most recommended option.
If you cannot use Nx Cloud, build your own caching server using the OpenAPI specification.
To learn more about migrating from custom task runners, please refer to this detailed guide.
NX_REJECT_UNKNOWN_LOCAL_CACHE
Section titled “NX_REJECT_UNKNOWN_LOCAL_CACHE”The NX_REJECT_UNKNOWN_LOCAL_CACHE environment variable does not work with the new database cache. We have introduced a new cache which will recognize artifacts from other machines.
If you are using NX_REJECT_UNKNOWN_LOCAL_CACHE to share your local cache on a network drive, you have a few options moving forward:
- Use Nx Cloud for your remote cache. This is the safest, lowest-maintenance, most recommended option.
- Build your own caching server using the OpenAPI specification.