mirror of
https://github.com/certd/certd.git
synced 2026-07-21 18:37:33 +08:00
chore: 1
This commit is contained in:
@@ -37,7 +37,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex-between mt-5">
|
<div class="flex-between mt-5">
|
||||||
<div class="flex-o"><fs-icon icon="ant-design:check-outlined" class="color-green mr-5" /> 监控站点数:</div>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
export function shouldSetDefaultNoCache(path: string, cacheControl?: string) {
|
export function shouldSetDefaultNoCache(path: string, cacheControl?: string) {
|
||||||
|
if(path === '/' || path === '/index.html' ){
|
||||||
|
//首页不管怎样都不要缓存
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (cacheControl) {
|
if (cacheControl) {
|
||||||
return false;
|
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", () => {
|
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", () => {
|
it("ignores non-html and non-api paths", () => {
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ export class MainConfiguration {
|
|||||||
await next();
|
await next();
|
||||||
const path = ctx.path;
|
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');
|
ctx.response.set('Cache-Control', 'public,max-age=0');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -138,6 +138,6 @@ export class MainConfiguration {
|
|||||||
|
|
||||||
logger.info('当前环境:', this.app.getEnv()); // prod
|
logger.info('当前环境:', this.app.getEnv()); // prod
|
||||||
// throw new Error("address family not supported")
|
// throw new Error("address family not supported")
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user