Skip to content

Commit 6957a4a

Browse files
JamesMGreeneheiskr
andauthored
Test bypassing Fastly for the Discussions, Packages, and Actions product families (#17611)
Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com> Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com>
1 parent d767029 commit 6957a4a

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

middleware/set-fastly-cache-headers.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
const FASTLY_TTL = process.env.FASTLY_TTL || String(60 * 60 * 24) // 24 hours
22
const STALE_TTL = String(60 * 10) // 10 minutes
33

4+
const BYPASS_FASTLY = process.env.TEST_BYPASS_FASTLY === 'true'
5+
const BYPASS_PRODUCTS = /^\/([a-z]{2})\/([a-z0-9._-]+@[a-z0-9._-]+\/)?(discussions|packages|actions)(\/.*|$)/i
6+
47
module.exports = (req, res, next) => {
8+
// Test bypassing Fastly for all pages inside of the Discussions product
9+
if (BYPASS_FASTLY && BYPASS_PRODUCTS.test(req.originalUrl)) {
10+
res.set({
11+
'surrogate-control': 'private, no-store',
12+
'cache-control': 'private, no-store'
13+
})
14+
return next()
15+
}
16+
517
res.set({
618

719
// Say you want Fastly to cache your content but you don't want it cached by browsers.

0 commit comments

Comments
 (0)