Edit this page

up.network up.cache.get(requestOptions)
JavaScript function

This feature is experimental. Please share your experiences so we know what to keep or change.

Returns a cached request matching the given request options.

The request may still be in flight.

Returns undefined if the given request is not currently cached.

Important

up.request() and up.render() will only write to the cache when a { cache } option is set.

Example

let request = up.cache.get({ url: '/foo' })

if (request) {
  let response = await request
  console.log("Response is %o", response)
} else {
  console.log("The path /foo has not been requested before!")
}

Parameters

requestOptions
required

The request options to match against the cache.

See options for up.request() for documentation.


Return value

The cached request.