diff --git a/package.json b/package.json index 88f05ebb4a..d37e25e8ac 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "fs-extra": "^10.1.0", "globby": "^13.1.2", "gzip-size": "^7.0.0", - "h3": "^0.8.3", + "h3": "^0.8.4", "hookable": "^5.4.1", "http-proxy": "^1.18.1", "is-primitive": "^3.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a0cc521cff..f677bcd5f3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -49,7 +49,7 @@ importers: fs-extra: ^10.1.0 globby: ^13.1.2 gzip-size: ^7.0.0 - h3: ^0.8.3 + h3: ^0.8.4 hookable: ^5.4.1 http-proxy: ^1.18.1 is-primitive: ^3.0.1 @@ -112,7 +112,7 @@ importers: fs-extra: 10.1.0 globby: 13.1.2 gzip-size: 7.0.0 - h3: 0.8.3 + h3: 0.8.4 hookable: 5.4.1 http-proxy: 1.18.1 is-primitive: 3.0.1 @@ -3163,8 +3163,8 @@ packages: duplexer: 0.1.2 dev: false - /h3/0.8.3: - resolution: {integrity: sha512-SUTWtkopWX04yzF0YGRwccNpvbRheTkib3PdOsjqx2hBhQcrmljMa28K8dXJd6Kn1LhPia8je093hpRdCObBPg==} + /h3/0.8.4: + resolution: {integrity: sha512-U7ZD/Te+LBS1IpUvsZRe+E+ZiA3zQS0u43DMrZ+raiVObeYe0G5F4Kr/g6Fn2fH92Np0ROkij/wEhkAMbUsBdQ==} dependencies: cookie-es: 0.5.0 destr: 1.1.1 @@ -5114,7 +5114,7 @@ packages: anymatch: 3.1.2 chokidar: 3.5.3 destr: 1.1.1 - h3: 0.8.3 + h3: 0.8.4 ioredis: 5.2.3 listhen: 0.3.4 mkdir: 0.0.2 diff --git a/src/runtime/cache.ts b/src/runtime/cache.ts index 83ece789e4..8765c7d08e 100644 --- a/src/runtime/cache.ts +++ b/src/runtime/cache.ts @@ -173,8 +173,8 @@ export function defineCachedEventHandler ( // Collect cachable headers const headers = event.res.getHeaders() - headers.Etag = `W/"${hash(body)}"` - headers['Last-Modified'] = new Date().toUTCString() + headers.etag = headers.Etag || headers.etag || `W/"${hash(body)}"` + headers['last-modified'] = headers['Last-Modified'] || headers['last-modified'] || new Date().toUTCString() const cacheControl = [] if (opts.swr) { if (opts.maxAge) { @@ -189,7 +189,7 @@ export function defineCachedEventHandler ( cacheControl.push(`max-age=${opts.maxAge}`) } if (cacheControl.length) { - headers['Cache-Control'] = cacheControl.join(', ') + headers['cache-control'] = cacheControl.join(', ') } // Create cache entry for response @@ -222,7 +222,7 @@ export function defineCachedEventHandler ( // Check for cache headers if (handleCacheHeaders(event, { - modifiedTime: new Date(response.headers['Last-Modified'] as string), + modifiedTime: new Date(response.headers['last-modified'] as string), etag: response.headers.etag as string, maxAge: opts.maxAge })) {