andyrichardson / andyrichardson/netlify-plugin-ttl-cache

File crawling performance

Aperta
#2 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
16
Fork
3
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Crawling the publish directory might be slow for some big sites. There might be a few opportunities of optimizing it:
- Each `readdir` already performs a `stat` syscall, so doing it again in https://github.com/andyrichardson/netlify-plugin-ttl-cache/blob/54127d8050d92f1335d37c7666c3161aafa82f11/src/index.js#L21 might be redundant
- If no `exclude` input is specified, there is no need to perform a `test()` on the filename. Even though the default regular expression `a^` should be fast and never match, it might become more expensive when performed thousands of times.
- Directories part of `exclude` might not need to crawled

There might also be some potential bugs with the directory crawling. For example, if a file was a symlink to one of its parent directory, would the crawline keep running until memory is exhausted?

I am wondering whether using a tried-and-tested library [like `readdirp`](https://github.com/paulmillr/readdirp) might help fix all of this, and also simplify the code? What are your thoughts?

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.