From 0ba2693c0e37c633304bee536ea4e1c282de38f8 Mon Sep 17 00:00:00 2001 From: Colby Gutierrez-Kraybill Date: Fri, 1 Dec 2017 13:50:43 -0500 Subject: [PATCH] Cache logged out account-nav.json and session Cache ^/fragment/account-nav.json and ^/session for logged out users --- bin/configure-fastly.js | 3 ++- bin/lib/fastly-config-methods.js | 3 ++- test/unit/test_fastly_config_methods.js | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/configure-fastly.js b/bin/configure-fastly.js index 657d83c56..543faa820 100644 --- a/bin/configure-fastly.js +++ b/bin/configure-fastly.js @@ -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' + diff --git a/bin/lib/fastly-config-methods.js b/bin/lib/fastly-config-methods.js index 1aaf21eef..750b1893b 100644 --- a/bin/lib/fastly-config-methods.js +++ b/bin/lib/fastly-config-methods.js @@ -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' + diff --git a/test/unit/test_fastly_config_methods.js b/test/unit/test_fastly_config_methods.js index 8799997dd..a75e0afd6 100644 --- a/test/unit/test_fastly_config_methods.js +++ b/test/unit/test_fastly_config_methods.js @@ -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' +