This commit is contained in:
eric
2026-03-08 10:27:28 -05:00
parent 7af7651104
commit d6c5135d97
3 changed files with 40 additions and 0 deletions

View File

@@ -176,3 +176,19 @@ app/lib/
client.ts # getMinioClient, uploadBuffer, generateObjectKey client.ts # getMinioClient, uploadBuffer, generateObjectKey
index.ts index.ts
``` ```
## 缓存与部署更新
项目已配置 `Cache-Control: no-store, no-cache`,部署后用户应能立即看到更新。若使用 **Cloudflare**,还需在控制台调整:
### Cloudflare 控制台设置
1. **Caching → Configuration**
- **Caching Level**:选 `Standard``Bypass`(开发/频繁更新时)
- **Browser Cache TTL**:选 `Respect Existing Headers`,以遵循源站 `Cache-Control`
2. **Caching → Cache Rules**(可选)
-`/*` 添加规则:`Cache eligibility` = Bypass`Edge TTL` = 0
3. **DNS**
- 记录 **TTL**:设为 `1`Auto`60` 秒,加快 DNS 变更生效

View File

@@ -4,6 +4,24 @@ const nextConfig: NextConfig = {
experimental: { experimental: {
serverActions: { bodySizeLimit: "25mb" }, serverActions: { bodySizeLimit: "25mb" },
}, },
async headers() {
const noCacheHeaders = [
{
key: "Cache-Control",
value: "no-store, no-cache, must-revalidate, proxy-revalidate",
},
{ key: "Pragma", value: "no-cache" },
{ key: "Expires", value: "0" },
];
return [
{ source: "/", headers: noCacheHeaders },
{
// 排除 /_next/ 静态资源(含 hash 可长期缓存),其余页面禁用缓存
source: "/:path((?!_next).*)",
headers: noCacheHeaders,
},
];
},
}; };
export default nextConfig; export default nextConfig;

6
public/_headers Normal file
View File

@@ -0,0 +1,6 @@
# Cloudflare Pages 自定义响应头(若使用 Cloudflare 部署)
# 禁用缓存,部署后用户立即看到更新
/*
Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate
Pragma: no-cache
Expires: 0