Skip to content

Commit

Permalink
Merge pull request #96 from holidayextras/expiry-headers
Browse files Browse the repository at this point in the history
Aggressive cache-expiry headers by default
  • Loading branch information
theninj4 committed Jan 25, 2016
2 parents 957364e + d1e7e2b commit f16cc00
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,5 @@
2015-01-11 - v1.1.0
2015-01-21 - Set better default CORS headers
2015-01-21 - v1.2.0
2015-01-25 - Aggressive cache-expiry headers by default
2015-01-25 - v1.3.0
4 changes: 3 additions & 1 deletion lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ app.use(function(req, res, next) {
"Content-Type": "application/vnd.api+json",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PATCH, DELETE, OPTIONS",
"Access-Control-Allow-Headers": req.headers["access-control-request-headers"] || ""
"Access-Control-Allow-Headers": req.headers["access-control-request-headers"] || "",
"Cache-Control": "private, must-revalidate, max-age=0",
"Expires": "Thu, 01 Jan 1970 00:00:00"
});

if (req.method === "OPTIONS") {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsonapi-server",
"version": "1.2.0",
"version": "1.3.0",
"description": "A config driven NodeJS framework implementing json:api",
"keywords": [
"jsonapi",
Expand Down
2 changes: 2 additions & 0 deletions test/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ describe("Testing jsonapi-server", function() {
assert.equal(res.headers["access-control-allow-origin"], "*", "should have CORS headers");
assert.equal(res.headers["access-control-allow-methods"], "GET, POST, PATCH, DELETE, OPTIONS", "should have CORS headers");
assert.equal(res.headers["access-control-allow-headers"], "", "should have CORS headers");
assert.equal(res.headers["cache-control"], "private, must-revalidate, max-age=0", "should have non-caching headers");
assert.equal(res.headers.expires, "Thu, 01 Jan 1970 00:00:00", "should have non-caching headers");
done();
});
});
Expand Down

0 comments on commit f16cc00

Please sign in to comment.