1
0
mirror of synced 2025-12-26 14:02:45 -05:00

make it possible to control the rendering cache LRU sizes (#29180)

* make it possible to control the rendering cache LRU sizes

* Update middleware/cache-full-rendering.js

Co-authored-by: Robert Sese <734194+rsese@users.noreply.github.com>

* Update middleware/cache-full-rendering.js

Co-authored-by: Robert Sese <734194+rsese@users.noreply.github.com>

Co-authored-by: Robert Sese <734194+rsese@users.noreply.github.com>
This commit is contained in:
Peter Bengtsson
2022-07-20 22:45:06 +02:00
committed by GitHub
parent fce5dea5bc
commit cc197ccbf1

View File

@@ -18,10 +18,14 @@ const HEADER_VALUE_TRANSFERRING = 'transferring'
const DISABLE_RENDERING_CACHE = Boolean(JSON.parse(process.env.DISABLE_RENDERING_CACHE || 'false'))
// NOTE: Apr 20, when storing about 200 cheerio instances, the total
// heap size becomes about 2.3GB.
const CHEERIO_CACHE_MAXSIZE = parseInt(process.env.CHEERIO_CACHE_MAXSIZE || 100, 10)
const GZIP_CACHE_MAXSIZE = parseInt(process.env.GZIP_CACHE_MAXSIZE || 1000, 10)
const cheerioCache = new QuickLRU({
// NOTE: Apr 20, when storing about 200 cheerio instances, the total
// heap size becomes about 2.3GB.
maxSize: 100,
maxSize: CHEERIO_CACHE_MAXSIZE,
// Don't use arrow function so we can access `this`.
onEviction: function onEviction() {
const { heapUsed } = process.memoryUsage()
@@ -30,7 +34,7 @@ const cheerioCache = new QuickLRU({
})
const gzipCache = new QuickLRU({
maxSize: 1000,
maxSize: GZIP_CACHE_MAXSIZE,
// Don't use arrow function so we can access `this`.
onEviction: function onEviction() {
const { heapUsed } = process.memoryUsage()