【问题标题】:How can I implement Cache-Control: public in Vercel如何在 Vercel 中实现 Cache-Control: public
【发布时间】:2021-11-22 00:28:27
【问题描述】:

我需要缓存控制我的个人网站,但我不知道应该如何或在哪里告诉浏览器缓存该网站。

我想用 Cache-Control: public, max-age=31536000, immutable 但不知道如何使用 Vercel 托管的 Next.js 应用程序。

【问题讨论】:

    标签: reactjs caching next.js vercel


    【解决方案1】:

    使用 Vercel 时,您可以在 vercel.json 文件中使用 configure the headers

    {
        "headers": [
            {
                "source": "/(.*)",
                "headers" : [
                    {
                        "key" : "Cache-Control",
                        "value" : "public, max-age=31536000, immutable"
                    }
                ]
            }
        ]
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-03-05
      • 2022-11-17
      • 1970-01-01
      • 2015-07-01
      • 2021-03-15
      • 2012-10-09
      • 1970-01-01
      相关资源
      最近更新 更多