• Public
  • Public/Protected
  • All

Interface CacheOptions

Options for controlling caching behavior in the browser and at the network edge.


  • CacheOptions



Optional browser

browser: BrowserCacheOptions | false

Sets the caching behavior in the browser. When set to false the caching in the browser is turned off.

Optional edge

edge: EdgeCacheOptions | false

Sets the caching behavior at edge. When set to false the caching in the edge is turned off. This also turns off queueing of potentially cacheable requests that platform performs automatically.

Note: if know for sure that a specific GET route will never cache then you should always set edge caching to false for it as it will disable GET request coalescing making your application faster.

Optional key

Allows you to split or normalize the cache space for a given route. Common use cases include:

  • serving multiple variants of the same URL based on a currency and/or language cookie.
  • caching different responses based on device type
  • ignoring all but a specific set of query parameters when looking up a response from the cache.


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

 new Router()
   .match('/some-path', ({ cache }) => {
       key: new CustomCacheKey()
         .excludeAllQueryParametersExcept('color', 'size')
         .addCookie('location', cookie => {
       edge: {
         maxAgeSeconds: 60 * 60

Optional prefetchUpstreamRequests

prefetchUpstreamRequests: undefined | false | true

If true, prefetch requests that match the route pattern will not be cached directly, but will instead force the Prefetcher to prefetch paths listed in the response's x-0-upstream-requests header.

Generated using TypeDoc