Skip to content

Commit

Permalink
feat: cache assets in Vercel adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
kidonng authored Jun 18, 2023
1 parent d2020c2 commit d3b92b3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/integrations/vercel/src/edge/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ export default function vercelEdge({
version: 3,
routes: [
...getRedirects(routes, _config),
{
src: '^/_astro/(.*)$',
headers: { 'cache-control': 'public, max-age=31536000, immutable' },
continue: true,
},
{ handle: 'filesystem' },
{ src: '/.*', dest: 'render' },
],
Expand Down
5 changes: 5 additions & 0 deletions packages/integrations/vercel/src/serverless/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ export default function vercelServerless({
version: 3,
routes: [
...getRedirects(routes, _config),
{
src: '^/_astro/(.*)$',
headers: { 'cache-control': 'public, max-age=31536000, immutable' },
continue: true,
},
{ handle: 'filesystem' },
{ src: '/.*', dest: 'render' },
],
Expand Down
10 changes: 9 additions & 1 deletion packages/integrations/vercel/src/static/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,15 @@ export default function vercelStatic({
// https://vercel.com/docs/build-output-api/v3#build-output-configuration
await writeJson(new URL(`./config.json`, getVercelOutput(_config.root)), {
version: 3,
routes: [...getRedirects(routes, _config), { handle: 'filesystem' }],
routes: [
...getRedirects(routes, _config),
{
src: '^/_astro/(.*)$',
headers: { 'cache-control': 'public, max-age=31536000, immutable' },
continue: true,
},
{ handle: 'filesystem' },
],
...(imageService || imagesConfig
? { images: imagesConfig ? imagesConfig : defaultImageConfig }
: {}),
Expand Down

0 comments on commit d3b92b3

Please sign in to comment.