问题工单后台管理
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

10 lines
414 B

// middlewares/cache.ts
import { Request, Response, NextFunction } from 'express'
export default function cacheMiddleware(req: Request, res: Response, next: NextFunction) {
if (process.env.NODE_ENV === 'production') { // 只在生产环境中启用缓存
const cacheTime = 60 * 60 * 24 // 设置缓存时间,这里为一天
res.setHeader('Cache-Control', `public, max-age=${cacheTime}`)
}
next()
}