mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-05-16 07:41:33 -04:00
Cache logged out account-nav.json and session
Cache ^/fragment/account-nav.json and ^/session for logged out users
This commit is contained in:
parent
fd6211bc6d
commit
0ba2693c0e
3 changed files with 6 additions and 3 deletions
|
@ -67,7 +67,8 @@ async.auto({
|
||||||
'std.tolower(req.http.Accept-Language)' +
|
'std.tolower(req.http.Accept-Language)' +
|
||||||
');\n' +
|
');\n' +
|
||||||
' }\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' +
|
' set req.http.Cookie = "scratchlanguage=" req.http.Cookie:scratchlanguage;\n' +
|
||||||
' } else {\n' +
|
' } else {\n' +
|
||||||
' return(pass);\n' +
|
' return(pass);\n' +
|
||||||
|
|
|
@ -93,7 +93,8 @@ var FastlyConfigMethods = {
|
||||||
setResponseTTL: function (condition) {
|
setResponseTTL: function (condition) {
|
||||||
return '' +
|
return '' +
|
||||||
'if (' + condition + ') {\n' +
|
'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' +
|
' set beresp.http.Vary = "Accept-Encoding, Accept-Language";\n' +
|
||||||
' unset beresp.http.set-cookie;\n' +
|
' unset beresp.http.set-cookie;\n' +
|
||||||
' return(deliver);\n' +
|
' return(deliver);\n' +
|
||||||
|
|
|
@ -63,7 +63,8 @@ tap.test('testSetTTL', function (t) {
|
||||||
var ttl = fastlyConfig.setResponseTTL('itsactuallyttyl');
|
var ttl = fastlyConfig.setResponseTTL('itsactuallyttyl');
|
||||||
t.equal(ttl, '' +
|
t.equal(ttl, '' +
|
||||||
'if (itsactuallyttyl) {\n' +
|
'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' +
|
' set beresp.http.Vary = "Accept-Encoding, Accept-Language";\n' +
|
||||||
' unset beresp.http.set-cookie;\n' +
|
' unset beresp.http.set-cookie;\n' +
|
||||||
' return(deliver);\n' +
|
' return(deliver);\n' +
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue