Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cache assets in Vercel adapter #7412

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/(.*)$',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _astro path can be configured through build.assets, it would be nice to derive this string from that too.

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