Skip to content

Commit

Permalink
Handling cache-control header rewrite better
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Feb 6, 2017
1 parent 0e660d1 commit 9794b25
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/tenso.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,12 @@ class Tenso {

if (!regex.get_rewrite.test(req.method)) {
if (!ref[0]["cache-control"] && this.server.config.headers["cache-control"]) {
ref[0]["cache-control"] = utility.clone(this.server.config.headers["cache-control"]) || "no-cache";
ref[0]["cache-control"] = utility.clone(this.server.config.headers["cache-control"]) || "public";
}

if (req.protect && !regex.private.test(ref[0]["cache-control"])) {
ref[0]["cache-control"] = "private, " + ref[0]["cache-control"].replace(/(private|public),\s/g, "");
ref[0]["cache-control"].replace(/(private|public)(,\s)?/g, "");
ref[0]["cache-control"] = "private" + (ref[0]["cache-control"].length > 0 ? ", " : "") + (ref[0]["cache-control"] || "");
}

if (!regex.modify.test(req.method) && regex.modify.test(req.allow) && this.server.config.security.csrf && res.locals[this.server.config.security.key]) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tenso",
"description": "Tensō is an elastic REST API gateway for node.js",
"version": "4.3.19",
"version": "4.3.20",
"homepage": "http://avoidwork.github.io/tenso",
"author": "Jason Mulligan <[email protected]>",
"repository": {
Expand Down

0 comments on commit 9794b25

Please sign in to comment.