Vercel 不缓存资产(图像、视频、音频)

Vercel not caching assets (image, video, audio)

我有一个包含大量静态资源(图像、视频、音频)的页面,这对页面性能的影响非常糟糕。

在检查网络选项卡时,我发现所有这些资产都没有缓存(缓存控制是 public, max-age=0, must-revalidate),尽管我使用 Vercel 进行部署。

我是不是遗漏了什么,或者有没有其他方法可以优化更多?

Vercel 使用他们的边缘网络在边缘缓存您的内容。

来自 Vercel 的 Caching 文档:

The Vercel Edge Network caches your content at the edge in order to serve data to your users as fast as possible.

Static caching is automatic for all deployments. This means that no changes need to be made to headers.

但是,您仍然可以通过覆盖 Cache-Control header 来自定义它。

By default we return a Cache-Control header containing public, max-age=0, must-revalidate to prevent clients (e.g. browsers) from caching the file locally. This gives you the most flexibility as users get the latest file from our Global CDN immediately after deploying. This can be overridden with the Headers property in your vercel.json file.