Skip to content

Commit

Permalink
Cache logged out account-nav.json and session
Browse files Browse the repository at this point in the history
Cache ^/fragment/account-nav.json and ^/session for logged out users
  • Loading branch information
colbygk committed Dec 1, 2017
1 parent fd6211b commit 0ba2693
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion bin/configure-fastly.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ async.auto({
'std.tolower(req.http.Accept-Language)' +
');\n' +
' }\n' +
' if (req.url ~ "^/projects/" && !req.http.Cookie:scratchsessionsid) {\n' +
' if (req.url ~ "^(/projects/|/fragment/account-nav.json|/session/)" && ' +
'!req.http.Cookie:scratchsessionsid) {\n' +
' set req.http.Cookie = "scratchlanguage=" req.http.Cookie:scratchlanguage;\n' +
' } else {\n' +
' return(pass);\n' +
Expand Down
3 changes: 2 additions & 1 deletion bin/lib/fastly-config-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ var FastlyConfigMethods = {
setResponseTTL: function (condition) {
return '' +
'if (' + condition + ') {\n' +
' if (req.url ~ "^/projects/" && !req.http.Cookie:scratchsessionsid) {\n' +
' if (req.url ~ "^(/projects/|/fragment/account-nav.json|/session/)" && ' +
'!req.http.Cookie:scratchsessionsid) {\n' +
' set beresp.http.Vary = "Accept-Encoding, Accept-Language";\n' +
' unset beresp.http.set-cookie;\n' +
' return(deliver);\n' +
Expand Down
3 changes: 2 additions & 1 deletion test/unit/test_fastly_config_methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ tap.test('testSetTTL', function (t) {
var ttl = fastlyConfig.setResponseTTL('itsactuallyttyl');
t.equal(ttl, '' +
'if (itsactuallyttyl) {\n' +
' if (req.url ~ "^/projects/" && !req.http.Cookie:scratchsessionsid) {\n' +
' if (req.url ~ "^(/projects/|/fragment/account-nav.json|/session/)" && ' +
'!req.http.Cookie:scratchsessionsid) {\n' +
' set beresp.http.Vary = "Accept-Encoding, Accept-Language";\n' +
' unset beresp.http.set-cookie;\n' +
' return(deliver);\n' +
Expand Down

0 comments on commit 0ba2693

Please sign in to comment.