forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cache archived enterproxy proxy responses much longer (github#23456)
* cache archived enterproxy proxy responses much longer * Update middleware/archived-enterprise-versions.js Co-authored-by: Rachael Sewell <rachmari@github.com> Co-authored-by: Rachael Sewell <rachmari@github.com>
- Loading branch information
Showing
7 changed files
with
63 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,29 @@ | ||
export default function setFastlySurrogateKey(req, res, next) { | ||
// Fastly provides a Soft Purge feature that allows you to mark content as outdated (stale) instead of permanently | ||
// purging and thereby deleting it from Fastly's caches. Objects invalidated with Soft Purge will be treated as | ||
// outdated (stale) while Fastly fetches a new version from origin. | ||
// | ||
// Use of a surrogate key is required for soft purging | ||
// https://docs.fastly.com/en/guides/soft-purges | ||
// https://docs.fastly.com/en/guides/getting-started-with-surrogate-keys | ||
res.set('surrogate-key', 'all-the-things') | ||
// Fastly provides a Soft Purge feature that allows you to mark content as outdated (stale) instead of permanently | ||
// purging and thereby deleting it from Fastly's caches. Objects invalidated with Soft Purge will be treated as | ||
// outdated (stale) while Fastly fetches a new version from origin. | ||
// | ||
// Use of a surrogate key is required for soft purging | ||
// https://docs.fastly.com/en/guides/soft-purges | ||
// https://docs.fastly.com/en/guides/getting-started-with-surrogate-keys | ||
|
||
// What the header needs to be called for Fastly to recognize it. | ||
const KEY = 'surrogate-key' | ||
|
||
export const SURROGATE_ENUMS = { | ||
DEFAULT: 'every-deployment', | ||
MANUAL: 'manual-purge', | ||
} | ||
|
||
export function setFastlySurrogateKey(res, enumKey) { | ||
if (!Object.values(SURROGATE_ENUMS).includes(enumKey)) { | ||
throw new Error( | ||
`Unrecognizes surrogate enumKey. ${enumKey} is not one of ${Object.values(SURROGATE_ENUMS)}` | ||
) | ||
} | ||
res.set(KEY, enumKey) | ||
} | ||
|
||
export default function setDefaultFastlySurrogateKey(req, res, next) { | ||
res.set(KEY, SURROGATE_ENUMS.DEFAULT) | ||
return next() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters