angularjs-query-cache
v1.0.2
Published
cache response to queries made using the $http service
Downloads
7
Maintainers
Readme
angularjs-query-cache
Sometimes you want to keep the result to a query you made previously. This module decorates the $http service to add better caching.
This module uses sessionStorage which means restarting the browser will reset the cache.
Usage
Set the _cache
field to true
in the options
object when making a get request using $http.
Optionally, you can see the max age (in milliseconds) on individual calls through the _maxAge
key.
var opts = {
_cache: true,
_maxAge: 5 * 60 * 1000 // <- this is the default value (5 minutes)
}
$http.get('https://api.my-service.io/endpoint', opts)
Installation
Using npm:
npm install --save angularjs-query-cache