angular-cache-buster

WebJar for angular-cache-buster

License

License

MIT
Categories

Categories

Angular User Interface Web Frameworks
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

angular-cache-buster
Last Version

Last Version

0.4.0
Release Date

Release Date

Type

Type

jar
Description

Description

angular-cache-buster
WebJar for angular-cache-buster
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/saintmac/angular-cache-buster

Download angular-cache-buster

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/angular-cache-buster/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>angular-cache-buster</artifactId>
    <version>0.4.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/angular-cache-buster/
implementation 'org.webjars.npm:angular-cache-buster:0.4.0'
// https://jarcasting.com/artifacts/org.webjars.npm/angular-cache-buster/
implementation ("org.webjars.npm:angular-cache-buster:0.4.0")
'org.webjars.npm:angular-cache-buster:jar:0.4.0'
<dependency org="org.webjars.npm" name="angular-cache-buster" rev="0.4.0">
  <artifact name="angular-cache-buster" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='angular-cache-buster', version='0.4.0')
)
libraryDependencies += "org.webjars.npm" % "angular-cache-buster" % "0.4.0"
[org.webjars.npm/angular-cache-buster "0.4.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Cache Buster for Angular JS $http and $resource. Especially useful with Internet Explorer (IE8, IE9)

install

bower install angular-cache-buster --save

In your app module definition, add ngCacheBuster as a dependency

angular.module('myApp', ['ngCacheBuster']);

configure

AngularCacheBuster adds a cache buster to any $http requests (and hence to $resource requests). Since you probably want to maintain browser caching for your views, partials or other routes, you can supply a list of regexes that will be matched against all URL's. By default the supplied matchlist is a whitelist (i.e. busting everything not matching an entry in the list) but you can also set it to be a blacklist, (i.e. busting everything matching entries)

For instance, if you want to bust everything except views in a 'partials' folder and images in a 'images' folder , you can configure AngularCacheBuster this way:

angular.module('yourApp', ['ngCacheBuster'])
  .config(function(httpRequestInterceptorCacheBusterProvider){
    httpRequestInterceptorCacheBusterProvider.setMatchlist([/.*partials.*/,/.*images.*/]);
  });

If instead you want to allow everything to be cached, except your "/api/users" and "api/orders" (assuming they are the only things that change frequently), you can supply a matchlist as before, but pass in a second boolean argument "blacklist" set to true as well:

angular.module('yourApp', ['ngCacheBuster'])
  .config(function(httpRequestInterceptorCacheBusterProvider){
    httpRequestInterceptorCacheBusterProvider.setMatchlist([/.*orders.*/,/.*users.*/],true);
  });

use

That's it! All your resource calls will have a cache buster added for anything not in the whitelist, or if you specified "blacklist", for everything matching the blacklist,

test

karma start to launch the tests

Versions

Version
0.4.0