Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface CacheOptions

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

Hierarchy

  • CacheOptions

Index

Properties

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.

Example

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

 new Router()
   .match('/some-path', ({ cache }) => {
     cache({
       key: new CustomCacheKey()
         .excludeAllQueryParametersExcept('color', 'size')
         .addCookie('currency')
         .addCookie('location', cookie => {
           cookie.group('na').byPattern('us|ca')
           cookie.group('eur').byPattern('de|fr|ee')
         }),
       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