In IE, when I make an update to or destroy an item in a list, the action is successful, but the updated list/data is not returned from the server, thus the list is not being updated in the view.
I've tried the following to no avail:
angular.module('casemanagerApp')
.config(function($stateProvider, $urlRouterProvider, RestangularProvider) {
if (!RestangularProvider.setDefaultHeaders) {
RestangularProvider.setDefaultHeaders({});
}
RestangularProvider.setDefaultHeaders({'If-Modified-Since': 'Mon, 26 Jul 1997 05:00:00 GMT'});
RestangularProvider.setDefaultHeaders({'Cache-Control': 'no-cache'});
RestangularProvider.setDefaultHeaders({'Pragma': 'no-cache'});
$stateProvider
...
});
Can anyone point me in the right direction for a solution to this?
I would recommend configuring $httpProvider
instead of RestangularProvider
since Restangular uses $http
behind the scenes:
angular.module('casemanagerApp')
.config(function($stateProvider, $urlRouterProvider, $httpProvider) {
if (!$httpProvider.defaults.headers.get) {
$httpProvider.defaults.headers.get = {};
}
$httpProvider.defaults.headers.get['If-Modified-Since'] = 'Mon, 26 Jul 1997 05:00:00 GMT';
$httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
$httpProvider.defaults.headers.get.Pragma = 'no-cache';
//...
});
EDIT
I just read through the restangular.js code and the setDefaultHeaders
function looks like it doesn't append more headers but override the default headers:
object.setDefaultHeaders = function(headers) {
config.defaultHeaders = headers;
object.defaultHeaders = config.defaultHeaders;
return this;
};
This means that you were only setting the 'Pragma'
header, which may not be enough to prevent caching.
You could try doing the following:
RestangularProvider.setDefaultHeaders({
'If-Modified-Since': 'Mon, 26 Jul 1997 05:00:00 GMT',
'Cache-Control': 'no-cache',
'Pragma': 'no-cache'
});
This way only Restangular calls will add the headers, and regular http
calls won't.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With