nitro icon indicating copy to clipboard operation
nitro copied to clipboard

Use `.data/cache` for cache storage by default

Open pi0 opened this issue 1 year ago • 2 comments

Currently we use {buildDir}/cache for cache storage by default but the downside is that, downstream frameworks (Nuxt) might choose to remove it entirely on each build causing to loose the cache.

As part of this directory migration, we might use a SQLite database now that we have useDatabase() to reduce FS IO overhead. (to be benchmarked also depends on https://github.com/unjs/unstorage/issues/400)

pi0 avatar Mar 06 '24 11:03 pi0

I think that moving the cache directory to .data/cache is a good idea for consistency between Nitro & other FE frameworks.

Regarding SQLite database, I am not 100% sure as it can be quite slow in edge environment (ex: D1) as they don't have replication yet. To be benchmarked indeed. There could also be a way of usingunstorage + SQLite driver.

Do you plan to use another database for the cache as well and make it configurable somehow?

atinux avatar Mar 06 '24 13:03 atinux

I am not 100% sure as it can be quite slow in edge environment (ex: D1)

Per preset, we can decide and it is (and remains) in "memory" by default.

I am suggesting different cache storage for Dev and Server deployment with SQLite support (Node.js, Bun). It needs to be benchmarked but in theory, reducing IO and batching it should gain perf.

Do you plan to use another database for the cache as well and make it configurable somehow?

Same as today, cache storage can be configured using unstorage cache: mount. See this relevant tracker: https://github.com/unjs/unstorage/issues/400

pi0 avatar Mar 06 '24 14:03 pi0