Skip to content

Commit 67803a6

Browse files
authored
Update Cache Control (#6874)
2 parents 7274e02 + 5737f71 commit 67803a6

File tree

3 files changed

+48
-31
lines changed

3 files changed

+48
-31
lines changed

website/api/get-discourse-comments.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ const PREVIEW_ENV = 'deploy-preview-'
99
// Set API endpoint and headers
1010
let discourse_endpoint = `https://discourse.getdbt.com`
1111
let headers = {
12-
'Accept': 'application/json',
13-
'Api-Key': DISCOURSE_DEVBLOG_API_KEY,
14-
'Api-Username': DISCOURSE_USER_SYSTEM,
15-
}
12+
Accept: "application/json",
13+
"Api-Key": DISCOURSE_DEVBLOG_API_KEY,
14+
"Api-Username": DISCOURSE_USER_SYSTEM,
15+
// Cache comments in the browser (max-age) & CDN (s-maxage) for 1 day
16+
"Cache-Control": "max-age=86400, s-maxage=86400 stale-while-revalidate",
17+
};
1618

1719
async function getDiscourseComments(request, response) {
1820
let topicId, comments, DISCOURSE_TOPIC_ID;

website/api/get-discourse-topics.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ async function getDiscourseTopics(request, response) {
99
// Set API endpoint and headers
1010
let discourse_endpoint = `https://discourse.getdbt.com`
1111
let headers = {
12-
'Accept': 'application/json',
13-
'Api-Key': DISCOURSE_API_KEY,
14-
'Api-Username': DISCOURSE_USER,
15-
}
12+
Accept: "application/json",
13+
"Api-Key": DISCOURSE_API_KEY,
14+
"Api-Username": DISCOURSE_USER,
15+
// Cache topics in the browser (max-age) & CDN (s-maxage) for 1 day
16+
"Cache-Control": "max-age=86400, s-maxage=86400 stale-while-revalidate",
17+
};
1618

1719
const query = buildQueryString(body)
1820
if(!query) throw new Error('Unable to build query string.')

website/vercel.json

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,42 @@
11
{
22
"cleanUrls": true,
33
"trailingSlash": false,
4+
"headers": [
5+
{
6+
"source": "/(.*)",
7+
"headers": [
8+
{
9+
"key": "X-Content-Type-Options",
10+
"value": "nosniff"
11+
},
12+
{
13+
"key": "X-Frame-Options",
14+
"value": "DENY"
15+
},
16+
{
17+
"key": "Content-Security-Policy",
18+
"value": "img-src 'self' data: https:; frame-ancestors 'self' https://*.mutinyhq.com https://*.getdbt.com"
19+
},
20+
{
21+
"key": "Strict-Transport-Security",
22+
"value": "max-age=63072000; includeSubDomains; preload"
23+
},
24+
{
25+
"key": "Cache-Control",
26+
"value": "max-age=0, s-maxage=86400 stale-while-revalidate"
27+
}
28+
]
29+
},
30+
{
31+
"source": "/:path*.(jpg|jpeg|png|svg|gif|webp)",
32+
"headers": [
33+
{
34+
"key": "Cache-Control",
35+
"value": "max-age=2678400, s-maxage=604800 stale-while-revalidate"
36+
}
37+
]
38+
}
39+
],
440
"redirects": [
541
{
642
"source": "/blog/dbt-cloud-api-postman-collection-announcement",
@@ -3671,28 +3707,5 @@
36713707
"destination": "https://www.getdbt.com/blog",
36723708
"permanent": true
36733709
}
3674-
],
3675-
"headers": [
3676-
{
3677-
"source": "/(.*)",
3678-
"headers": [
3679-
{
3680-
"key": "X-Content-Type-Options",
3681-
"value": "nosniff"
3682-
},
3683-
{
3684-
"key": "X-Frame-Options",
3685-
"value": "DENY"
3686-
},
3687-
{
3688-
"key": "Content-Security-Policy",
3689-
"value": "img-src 'self' data: https:; frame-ancestors 'self' https://*.mutinyhq.com https://*.getdbt.com"
3690-
},
3691-
{
3692-
"key": "Strict-Transport-Security",
3693-
"value": "max-age=63072000; includeSubDomains; preload"
3694-
}
3695-
]
3696-
}
36973710
]
36983711
}

0 commit comments

Comments
 (0)