bugfix: 当原请求缓存时间大于配置缓存时间时,最终缓存时间计算错误的问题修复。
parent
29bc385387
commit
aa4017d5c0
|
@ -63,10 +63,10 @@ module.exports = {
|
||||||
|
|
||||||
// 判断原max-age是否大于新max-age
|
// 判断原max-age是否大于新max-age
|
||||||
if (originalHeaders.cacheControl) {
|
if (originalHeaders.cacheControl) {
|
||||||
const maxAgeMatch = originalHeaders.cacheControl.value.match(/max-age=(\d+)/)
|
const maxAgeMatch = originalHeaders.cacheControl.value.match(/max-age=(\d+)/i)
|
||||||
if (maxAgeMatch && maxAgeMatch[1] > maxAge) {
|
if (maxAgeMatch && Number.parseInt(maxAgeMatch[1]) > maxAge) {
|
||||||
if (interceptOpt.cacheImmutable !== false && !originalHeaders.cacheControl.value.includes('immutable')) {
|
if (interceptOpt.cacheImmutable !== false && !originalHeaders.cacheControl.value.includes('immutable')) {
|
||||||
maxAge = maxAgeMatch[1]
|
maxAge = Number.parseInt(maxAgeMatch[1])
|
||||||
} else {
|
} else {
|
||||||
const url = `${rOptions.method} ➜ ${rOptions.protocol}//${rOptions.hostname}:${rOptions.port}${req.url}`
|
const url = `${rOptions.method} ➜ ${rOptions.protocol}//${rOptions.hostname}:${rOptions.port}${req.url}`
|
||||||
res.setHeader('DS-Cache-Response-Interceptor', `skip: ${maxAgeMatch[1]} > ${maxAge}`)
|
res.setHeader('DS-Cache-Response-Interceptor', `skip: ${maxAgeMatch[1]} > ${maxAge}`)
|
||||||
|
|
Loading…
Reference in New Issue