Skip to content

Commit f16cc00

Browse files
author
Oliver Rumbelow
committed
Merge pull request #96 from holidayextras/expiry-headers
Aggressive cache-expiry headers by default
2 parents 957364e + d1e7e2b commit f16cc00

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,5 @@
7777
2015-01-11 - v1.1.0
7878
2015-01-21 - Set better default CORS headers
7979
2015-01-21 - v1.2.0
80+
2015-01-25 - Aggressive cache-expiry headers by default
81+
2015-01-25 - v1.3.0

lib/router.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ app.use(function(req, res, next) {
5151
"Content-Type": "application/vnd.api+json",
5252
"Access-Control-Allow-Origin": "*",
5353
"Access-Control-Allow-Methods": "GET, POST, PATCH, DELETE, OPTIONS",
54-
"Access-Control-Allow-Headers": req.headers["access-control-request-headers"] || ""
54+
"Access-Control-Allow-Headers": req.headers["access-control-request-headers"] || "",
55+
"Cache-Control": "private, must-revalidate, max-age=0",
56+
"Expires": "Thu, 01 Jan 1970 00:00:00"
5557
});
5658

5759
if (req.method === "OPTIONS") {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jsonapi-server",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"description": "A config driven NodeJS framework implementing json:api",
55
"keywords": [
66
"jsonapi",

test/options.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ describe("Testing jsonapi-server", function() {
2020
assert.equal(res.headers["access-control-allow-origin"], "*", "should have CORS headers");
2121
assert.equal(res.headers["access-control-allow-methods"], "GET, POST, PATCH, DELETE, OPTIONS", "should have CORS headers");
2222
assert.equal(res.headers["access-control-allow-headers"], "", "should have CORS headers");
23+
assert.equal(res.headers["cache-control"], "private, must-revalidate, max-age=0", "should have non-caching headers");
24+
assert.equal(res.headers.expires, "Thu, 01 Jan 1970 00:00:00", "should have non-caching headers");
2325
done();
2426
});
2527
});

0 commit comments

Comments
 (0)