Refactor to two caches. One for bots and one for anonymous users

This commit is contained in:
Tim Donohue
2023-02-03 12:55:23 -06:00
parent 36085e4854
commit bae63111e7
6 changed files with 178 additions and 73 deletions

View File

@@ -76,10 +76,22 @@ export class DefaultAppConfig implements AppConfig {
},
// In-memory cache of server-side rendered content
serverSide: {
// Maximum number of pages (rendered via SSR) to cache. Set to zero to disable server side caching.
max: 100,
// Amount of time after which cached pages are considered stale (in ms)
timeToLive: 15 * 60 * 1000 // 15 minutes
// Cache specific to known bots. Allows you to serve cached contents to bots only.
// Defaults to caching 1,000 pages. Each page expires after 1 day
botCache: {
// Maximum number of pages (rendered via SSR) to cache. Setting max=0 disables the cache.
max: 1000,
// Amount of time after which cached pages are considered stale (in ms)
timeToLive: 24 * 60 * 60 * 1000, // 1 day
},
// Cache specific to anonymous users. Allows you to serve cached content to non-authenticated users.
// Defaults to caching 0 pages. But, when enabled, each page expires after 10 seconds (to minimize anonymous users seeing out-of-date content)
anonymousCache: {
// Maximum number of pages (rendered via SSR) to cache. Setting max=0 disables the cache.
max: 0, // disabled by default
// Amount of time after which cached pages are considered stale (in ms)
timeToLive: 10 * 1000, // 10 seconds
}
}
};