set expires header corresponding to maxAge (#1651)

* set expires header corresponding to maxAge

* add tests
This commit is contained in:
Danial
2018-04-22 13:48:01 +12:00
committed by GitHub
parent 2ded83f8a6
commit 8fda86fcf1
2 changed files with 16 additions and 4 deletions

View File

@@ -105,6 +105,17 @@ describe('The request handler', function() {
expect(handlerCallCount).to.equal(1);
});
it('should set the expires header to current time', async function () {
const res = await fetch(`${baseUri}/testing/123.json`);
expect(res.headers.get('expires')).to.equal(res.headers.get('date'));
});
it('should set the expires header to current time + max-age', async function () {
const res = await fetch(`${baseUri}/testing/123.json?maxAge=3600`);
const expectedExpiry = new Date(+(new Date(res.headers.get('date'))) + 3600000).toGMTString();
expect(res.headers.get('expires')).to.equal(expectedExpiry);
});
describe('the cache key', function () {
const expectedCacheKey = '/testing/123.json?colorB=123&label=foo';
it('should match expected and use canonical order - 1', async function () {