• Public
  • Public/Protected
  • All

Interface EdgeCacheOptions

Options for controlling caching behavior at edge


  • EdgeCacheOptions



Optional forcePrivateCaching

forcePrivateCaching: undefined | false | true

Allows you to force caching of responses marked as private in their cache-control header. This option must be used with utmost care to avoid leaking private information.


 import { Router, CustomCacheKey } from '@layer0/core/router'

 new Router()
   .match('/private/path', ({ cache }) => {
       edge: {
         maxAgeSeconds: 60 * 60,
         key: new CustomCacheKey()
         forcePrivateCaching: true,

Optional maxAgeSeconds

maxAgeSeconds: undefined | number

The maximum number of seconds that a response is served from the cache until it is considered stale. Unless staleWhileRevalidate is specified, stale responses will not be returned to the browser.

Optional staleWhileRevalidateSeconds

staleWhileRevalidateSeconds: undefined | number

Extends the duration that a response will be served from the cache after it has become stale. When using staleWhileRevalidate, if Layer0 receives a request for a stale asset, the cached response will be served and a fresh response will be concurrently fetch so that it can be served for future requests. The stale response will continue to be served until the fresh fetched.

Generated using TypeDoc