Skip to content

Commit

Permalink
Update Cache Control (#6874)
Browse files Browse the repository at this point in the history
  • Loading branch information
JKarlavige authored Feb 6, 2025
2 parents 7274e02 + 5737f71 commit 67803a6
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 31 deletions.
10 changes: 6 additions & 4 deletions website/api/get-discourse-comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ const PREVIEW_ENV = 'deploy-preview-'
// Set API endpoint and headers
let discourse_endpoint = `https://discourse.getdbt.com`
let headers = {
'Accept': 'application/json',
'Api-Key': DISCOURSE_DEVBLOG_API_KEY,
'Api-Username': DISCOURSE_USER_SYSTEM,
}
Accept: "application/json",
"Api-Key": DISCOURSE_DEVBLOG_API_KEY,
"Api-Username": DISCOURSE_USER_SYSTEM,
// Cache comments in the browser (max-age) & CDN (s-maxage) for 1 day
"Cache-Control": "max-age=86400, s-maxage=86400 stale-while-revalidate",
};

async function getDiscourseComments(request, response) {
let topicId, comments, DISCOURSE_TOPIC_ID;
Expand Down
10 changes: 6 additions & 4 deletions website/api/get-discourse-topics.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ async function getDiscourseTopics(request, response) {
// Set API endpoint and headers
let discourse_endpoint = `https://discourse.getdbt.com`
let headers = {
'Accept': 'application/json',
'Api-Key': DISCOURSE_API_KEY,
'Api-Username': DISCOURSE_USER,
}
Accept: "application/json",
"Api-Key": DISCOURSE_API_KEY,
"Api-Username": DISCOURSE_USER,
// Cache topics in the browser (max-age) & CDN (s-maxage) for 1 day
"Cache-Control": "max-age=86400, s-maxage=86400 stale-while-revalidate",
};

const query = buildQueryString(body)
if(!query) throw new Error('Unable to build query string.')
Expand Down
59 changes: 36 additions & 23 deletions website/vercel.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
{
"cleanUrls": true,
"trailingSlash": false,
"headers": [
{
"source": "/(.*)",
"headers": [
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-Frame-Options",
"value": "DENY"
},
{
"key": "Content-Security-Policy",
"value": "img-src 'self' data: https:; frame-ancestors 'self' https://*.mutinyhq.com https://*.getdbt.com"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=63072000; includeSubDomains; preload"
},
{
"key": "Cache-Control",
"value": "max-age=0, s-maxage=86400 stale-while-revalidate"
}
]
},
{
"source": "/:path*.(jpg|jpeg|png|svg|gif|webp)",
"headers": [
{
"key": "Cache-Control",
"value": "max-age=2678400, s-maxage=604800 stale-while-revalidate"
}
]
}
],
"redirects": [
{
"source": "/blog/dbt-cloud-api-postman-collection-announcement",
Expand Down Expand Up @@ -3671,28 +3707,5 @@
"destination": "https://www.getdbt.com/blog",
"permanent": true
}
],
"headers": [
{
"source": "/(.*)",
"headers": [
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-Frame-Options",
"value": "DENY"
},
{
"key": "Content-Security-Policy",
"value": "img-src 'self' data: https:; frame-ancestors 'self' https://*.mutinyhq.com https://*.getdbt.com"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=63072000; includeSubDomains; preload"
}
]
}
]
}

0 comments on commit 67803a6

Please sign in to comment.