mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-28 17:41:54 +08:00
Chore: print statusCode when cache miss
This commit is contained in:
@@ -225,12 +225,11 @@ export class Cache<S = string> {
|
||||
|
||||
const etag = this.get(etagKey);
|
||||
|
||||
const onMiss = (resp: Response) => {
|
||||
const onMiss = async (resp: Response) => {
|
||||
const serializer = 'serializer' in opt ? opt.serializer : identity as any;
|
||||
|
||||
const promise = fn(resp);
|
||||
const value = await fn(resp);
|
||||
|
||||
return promise.then((value) => {
|
||||
if (resp.headers.has('ETag')) {
|
||||
let serverETag = resp.headers.get('ETag')!;
|
||||
// FUCK someonewhocares.org
|
||||
@@ -238,7 +237,7 @@ export class Cache<S = string> {
|
||||
serverETag = serverETag.replace('-gzip', '');
|
||||
}
|
||||
|
||||
console.log(picocolors.yellow('[cache] miss'), url, { cachedETag: etag, serverETag });
|
||||
console.log(picocolors.yellow('[cache] miss'), url, { status: resp.status, cachedETag: etag, serverETag });
|
||||
|
||||
this.set(etagKey, serverETag, TTL.ONE_WEEK_STATIC);
|
||||
this.set(cachedKey, serializer(value), TTL.ONE_WEEK_STATIC);
|
||||
@@ -252,7 +251,6 @@ export class Cache<S = string> {
|
||||
}
|
||||
|
||||
return value;
|
||||
});
|
||||
};
|
||||
|
||||
const cached = this.get(cachedKey);
|
||||
|
||||
Reference in New Issue
Block a user