diff --git a/website/api/get-discourse-comments.js b/website/api/get-discourse-comments.js index 5ac59cfe5f2..2409de0a61b 100644 --- a/website/api/get-discourse-comments.js +++ b/website/api/get-discourse-comments.js @@ -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; diff --git a/website/api/get-discourse-topics.js b/website/api/get-discourse-topics.js index 90d6e5af80e..503358a9e9f 100644 --- a/website/api/get-discourse-topics.js +++ b/website/api/get-discourse-topics.js @@ -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.') diff --git a/website/vercel.json b/website/vercel.json index 61873b3f067..849a133c520 100644 --- a/website/vercel.json +++ b/website/vercel.json @@ -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", @@ -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" - } - ] - } ] }