From b6d173e664597c0ffe7419c076e15276d719dca0 Mon Sep 17 00:00:00 2001 From: Paul Van Eck Date: Sat, 10 Oct 2015 11:40:44 -0700 Subject: [PATCH] Force no caching for Angular $http requests There were issues with IE caching angular $http get requests, so this patch will ensure no caching. Change-Id: If932f307f8eeb636a99d2296b0053030057182f9 Closes-Bug: #1504818 --- refstack-ui/app/app.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/refstack-ui/app/app.js b/refstack-ui/app/app.js index 471f4517..359825cc 100644 --- a/refstack-ui/app/app.js +++ b/refstack-ui/app/app.js @@ -76,6 +76,24 @@ }); } + angular + .module('refstackApp') + .config(disableHttpCache); + + disableHttpCache.$inject = ['$httpProvider']; + + /** + * Disable caching in $http requests. This is primarily for IE, as it + * tends to cache Angular IE requests. + */ + function disableHttpCache($httpProvider) { + if (!$httpProvider.defaults.headers.get) { + $httpProvider.defaults.headers.get = {}; + } + $httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache'; + $httpProvider.defaults.headers.get.Pragma = 'no-cache'; + } + angular .module('refstackApp') .run(setup);