add vary header to honor authorization header when caching
This commit is contained in:
parent
39bd6694f2
commit
b0eacb2a79
@ -5,6 +5,7 @@ module.exports = function apikeyToken () {
|
||||
const apikeyCredentials = getApikeyCredentialsFromRequest(req);
|
||||
res.locals.api_key = apikeyCredentials.token;
|
||||
res.locals.apikeyUsername = apikeyCredentials.username;
|
||||
res.set('vary', 'Authorization'); //Honor Authorization header when caching.
|
||||
return next();
|
||||
};
|
||||
};
|
||||
|
1
test/acceptance/cache/cache_headers.js
vendored
1
test/acceptance/cache/cache_headers.js
vendored
@ -155,6 +155,7 @@ describe('get requests with cache headers', function() {
|
||||
|
||||
assert.ok(res.headers['x-cache-channel']);
|
||||
assert.ok(res.headers['surrogate-key']);
|
||||
assert.ok(res.headers['vary'] === 'Authorization');
|
||||
if (expectedCacheHeaders) {
|
||||
validateXChannelHeaders(res.headers, expectedCacheHeaders);
|
||||
assert.equal(res.headers['surrogate-key'], expectedCacheHeaders.surrogate_keys);
|
||||
|
Loading…
Reference in New Issue
Block a user