Skip to content

Commit

Permalink
Add Cache-Control header in response to requests for immutable reso…
Browse files Browse the repository at this point in the history
…urces
  • Loading branch information
CMeeg committed Nov 15, 2023
1 parent 057c036 commit 1cfd5bd
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const buildId = process.env.NEXT_PUBLIC_BUILD_ID || null
const customDomainName = process.env.SERVICE_WEB_CUSTOM_DOMAIN_NAME || ''

const remotePatterns = []
const headers = []
const rewrites = {}
const redirects = []

Expand All @@ -25,6 +26,17 @@ if (buildId) {
destination: '/:path*'
}
]

// Also add a cache control header as these resources are immutable for each build
headers.push({
source: `/${buildId}/:path*`,
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable'
}
]
})
}

if (customDomainName) {
Expand Down Expand Up @@ -62,6 +74,9 @@ const nextConfig = {
images: {
remotePatterns
},
async headers() {
return headers
},
async rewrites() {
return rewrites
},
Expand Down

0 comments on commit 1cfd5bd

Please sign in to comment.