bugfix: 当原请求缓存时间大于配置缓存时间时,最终缓存时间计算错误的问题修复。

pull/406/head
王良 2024-11-26 22:00:00 +08:00
parent 29bc385387
commit aa4017d5c0
1 changed files with 3 additions and 3 deletions

View File

@ -63,10 +63,10 @@ module.exports = {
// 判断原max-age是否大于新max-age
if (originalHeaders.cacheControl) {
const maxAgeMatch = originalHeaders.cacheControl.value.match(/max-age=(\d+)/)
if (maxAgeMatch && maxAgeMatch[1] > maxAge) {
const maxAgeMatch = originalHeaders.cacheControl.value.match(/max-age=(\d+)/i)
if (maxAgeMatch && Number.parseInt(maxAgeMatch[1]) > maxAge) {
if (interceptOpt.cacheImmutable !== false && !originalHeaders.cacheControl.value.includes('immutable')) {
maxAge = maxAgeMatch[1]
maxAge = Number.parseInt(maxAgeMatch[1])
} else {
const url = `${rOptions.method}${rOptions.protocol}//${rOptions.hostname}:${rOptions.port}${req.url}`
res.setHeader('DS-Cache-Response-Interceptor', `skip: ${maxAgeMatch[1]} > ${maxAge}`)