Skip to content

Commit

Permalink
Fix IE-related JSON caching issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
mnaughto committed Nov 18, 2015
1 parent 6c40217 commit 6334e09
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/responses/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ module.exports.buildResponse = function (req, res, data, options, config) {

// If appropriate, serve data as JSON(P)
if (req.wantsJSON) {
res.header('Cache-Control', 'no-cache, max-age=0, maxage=0, no-store, must-revalidate');
res.header('Pragma', 'no-cache');
res.header('Expires', -1);
res.header('Pragma', 'no-store');
return res.jsonx(json);
}

Expand All @@ -121,6 +125,10 @@ module.exports.buildResponse = function (req, res, data, options, config) {
else {
if(config.isGuessView) {
return res.guessView({ data: data }, function couldNotGuessView () {
res.header('Cache-Control', 'no-cache, max-age=0, maxage=0, no-store, must-revalidate');
res.header('Pragma', 'no-cache');
res.header('Expires', -1);
res.header('Pragma', 'no-store');
return res.jsonx(data);
});
} else {
Expand All @@ -138,6 +146,11 @@ module.exports.buildResponse = function (req, res, data, options, config) {
else {
sails.log.warn('res.'+config.name+'() :: When attempting to render error page view, an error occured (sending JSON instead). Details: ', err);
}

res.header('Cache-Control', 'no-cache, max-age=0, maxage=0, no-store, must-revalidate');
res.header('Pragma', 'no-cache');
res.header('Expires', -1);
res.header('Pragma', 'no-store');
return res.jsonx(data);
}

Expand Down

0 comments on commit 6334e09

Please sign in to comment.