mirror of
https://github.com/certd/certd.git
synced 2026-05-21 01:37:37 +08:00
fix(certd-server): 调整首页缓存控制头的判断逻辑
新增对首页路径 / 和 /index.html 的强制不缓存处理,确保首页始终获取最新内容
This commit is contained in:
@@ -124,7 +124,9 @@ export class MainConfiguration {
|
|||||||
|
|
||||||
this.app.getMiddleware().insertFirst(async (ctx: IMidwayKoaContext, next: NextFunction) => {
|
this.app.getMiddleware().insertFirst(async (ctx: IMidwayKoaContext, next: NextFunction) => {
|
||||||
await next();
|
await next();
|
||||||
if (shouldSetDefaultNoCache(ctx.path, ctx.response.get('Cache-Control'))) {
|
const path = ctx.path;
|
||||||
|
// 如果是首页则强制设置为不缓存
|
||||||
|
if (path === '/' || path === '/index.html' || shouldSetDefaultNoCache(path, ctx.response.get('Cache-Control')) ) {
|
||||||
ctx.response.set('Cache-Control', 'public,max-age=0');
|
ctx.response.set('Cache-Control', 'public,max-age=0');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user