From 03d38c8b8a9e07bc06c364f6337855c6109fc5c9 Mon Sep 17 00:00:00 2001 From: Lloyd Hilaiel <lloyd@hilaiel.com> Date: Tue, 24 Jan 2012 12:23:50 -0700 Subject: [PATCH] add Cache-Control headers to prevent IE from caching api responses for in-tree testing primary --- scripts/serve_example_primary.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/serve_example_primary.js b/scripts/serve_example_primary.js index 10a548b43..bf56c8d24 100755 --- a/scripts/serve_example_primary.js +++ b/scripts/serve_example_primary.js @@ -51,6 +51,15 @@ exampleServer.use(express.static(path.join(__dirname, "..", "example", "primary" exampleServer.use(express.bodyParser()); +const API_PREFIX = '/api/'; + +exampleServer.use(function(req, resp, next) { + if (req.url.substr(0, API_PREFIX.length) === API_PREFIX) { + resp.setHeader('Cache-Control', 'no-store, max-age=0'); + } + next(); +}); + exampleServer.get("/api/whoami", function (req, res) { if (req.session && typeof req.session.user === 'string') return res.json(req.session.user); return res.json(null); -- GitLab