mirror of
https://github.com/certd/certd.git
synced 2026-06-13 20:57:33 +08:00
chore: 1
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
</div>
|
||||
<div class="flex-between mt-5">
|
||||
<div class="flex-o"><fs-icon icon="ant-design:check-outlined" class="color-green mr-5" /> 监控站点数:</div>
|
||||
<suite-value :model-value="detail.monitorCount.max" :used="detail.monitorCount.used" unit="次" />
|
||||
<suite-value :model-value="detail.monitorCount.max" :used="detail.monitorCount.used" unit="个" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
export function shouldSetDefaultNoCache(path: string, cacheControl?: string) {
|
||||
if(path === '/' || path === '/index.html' ){
|
||||
//首页不管怎样都不要缓存
|
||||
return true;
|
||||
}
|
||||
if (cacheControl) {
|
||||
return false;
|
||||
}
|
||||
return path === '/' || path === '/index.html' || path.startsWith('/api');
|
||||
// api也不要缓存,如果他本身有设置缓存除外
|
||||
return path.startsWith('/api');
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ describe("shouldSetDefaultNoCache", () => {
|
||||
});
|
||||
|
||||
it("keeps explicit cache headers from file responses", () => {
|
||||
assert.equal(shouldSetDefaultNoCache("/api/basic/file/download", "public,max-age=259200"), false);
|
||||
assert.equal(shouldSetDefaultNoCache("/", "public,max-age=259200"), true);
|
||||
assert.equal(shouldSetDefaultNoCache("/index.html", "public,max-age=259200"), true);
|
||||
assert.equal(shouldSetDefaultNoCache("/api/basic/file/download", "public,max-age=259200"), false);
|
||||
});
|
||||
|
||||
it("ignores non-html and non-api paths", () => {
|
||||
|
||||
@@ -126,7 +126,7 @@ export class MainConfiguration {
|
||||
await next();
|
||||
const path = ctx.path;
|
||||
// 如果是首页则强制设置为不缓存
|
||||
if (path === '/' || path === '/index.html' || shouldSetDefaultNoCache(path, ctx.response.get('Cache-Control')) ) {
|
||||
if (shouldSetDefaultNoCache(path, ctx.response.get('Cache-Control')) ) {
|
||||
ctx.response.set('Cache-Control', 'public,max-age=0');
|
||||
}
|
||||
});
|
||||
@@ -138,6 +138,6 @@ export class MainConfiguration {
|
||||
|
||||
logger.info('当前环境:', this.app.getEnv()); // prod
|
||||
// throw new Error("address family not supported")
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user