Skip to content

Instantly share code, notes, and snippets.

@twilson63
Created January 23, 2014 13:57
Show Gist options
  • Select an option

  • Save twilson63/8578778 to your computer and use it in GitHub Desktop.

Select an option

Save twilson63/8578778 to your computer and use it in GitHub Desktop.
config(function($httpProvider) {
$httpProvider.interceptors.push('cacheSlayer');
})
.factory('cacheSlayer', function($injector, $q) {
return {
request: function(config) {
if (config.method === 'GET' && /^\/api/.test(config.url)) {
var sep = config.url.indexOf('?') === -1 ? '?' : '&';
config.url = config.url + sep + 'cacheSlayer=' + new Date().getTime();
}
return config || $q.when(config);
}
};
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment