const crypto = require('crypto');{security: [ 'JWT' ],description: () => '获取wkt',// pathParmeters: pathParmeters4PID,type: 'GET',url: ({ baseUrl }) => `${baseUrl}/ssss`,async fun(req, res) {res.setHeader('Cache-Control', 'no-cache')const hash = crypto.createHash('sha1').update(content).digest('hex')res.setHeader('Etag', hash)if(req.headers['if-none-match'] === hash){console.log('Etag协商缓存命中.....')res.statusCode = 304res.end()return}if (new Date(req.headers['if-modified-since']).getTime() + 15 * 1000 > Date.now()) {console.log('协商缓存命中....')Util.ResponseUtil.json({res, status: 304,})return}const data = {name: 'asgsa',age: 14,}// 强缓存 http1.0res.setHeader('Expires', new Date(Date.now() + 5 * 1000).toUTCString())// 强缓存 http1.1 (优先)res.setHeader('Cache-Control', 'max-age=10')// 协商缓存 http1.0res.setHeader('last-modified', new Date().toUTCString())// // 协商缓存 http1.1 (优先)Util.ResponseUtil.json({ res, data })},},
