No cache IE/Edge ajax db GETs via server response

Closes #3929
This commit is contained in:
Matt Lott 2016-09-13 13:42:13 -07:00
parent 5c4e9ca417
commit cf34d1c935

View file

@ -199,11 +199,25 @@ exports.setupMiddleware = (app) ->
setupPassportMiddleware app
setupOneSecondDelayMiddleware app
setupRedirectMiddleware app
setupAjaxCaching app
setupErrorMiddleware app
setupJavascript404s app
###Routing function implementations###
setupAjaxCaching = (app) ->
# IE/Edge are more aggresive about caching than other browsers, so we'll override their caching here.
# Assumes our CDN will override these with it's own caching rules.
app.get '/db/*', (req, res, next) ->
return next() unless req.xhr
# http://stackoverflow.com/questions/19999388/check-if-user-is-using-ie-with-jquery
userAgent = req.header('User-Agent') or ""
if userAgent.indexOf('MSIE ') > 0 or !!userAgent.match(/Trident.*rv\:11\.|Edge\/\d+/)
res.header 'Cache-Control', 'no-cache, no-store, must-revalidate'
res.header 'Pragma', 'no-cache'
res.header 'Expires', 0
next()
setupJavascript404s = (app) ->
app.get '/javascripts/*', (req, res) ->
res.status(404).send('Not found')