# angular.service.$xhr.cache

Work in Progress This page is currently being revised. It might be incomplete or contain inaccuracies.

## Description

Acts just like the `$xhr` service but caches responses for `GET` requests. All cache misses are delegated to the $xhr service.

## Dependencies

- `$xhr.bulk`
- `$defer`
- `$xhr.error`
- `$log`

## Usage

    cache(method, url[, post], success[, error][, verifyCache][, sync]);

### Parameters

- `method – {string} –`

  HTTP method.

- `url – {string} –`

  Destination URL.

- `post(optional) – {(string|Object)} –`

  Request body.

- `success – {function(number, (string|Object))} –`

  Response success callback.

- `error(optional) – {function(number, (string|Object))} –`

  Response error callback.

- `verifyCache(optional=false) – {boolean} –`

  If `true` then a result is immediately returned from cache (if present) while a request is sent to the server for a fresh response that will update the cached entry. The `success` function will be called when the response is received.

- `sync(optional=false) – {boolean} –`

  in case of cache hit execute `success` synchronously.

## Properties

- ### delegate

  Function to delegate all the cache misses to. Defaults to the `$xhr` service.

- ### data

  The hashmap where all cached entries are stored.