调整缓存时间

master
yutent 2024-07-23 12:00:16 +08:00
parent 1021ef2666
commit 9f78c93adc
2 changed files with 5 additions and 5 deletions

View File

@ -123,7 +123,7 @@ export default class Response {
}
// 文件下载
sendfile(target, filename = 'untitled') {
sendfile(target, filename = 'untitled', expires = 3600) {
if (this.#ended) {
return
}
@ -151,7 +151,7 @@ export default class Response {
}
}
this.expires = 3600
this.expires = expires
if (Buffer.isBuffer(target)) {
data = target
@ -184,14 +184,14 @@ export default class Response {
this.body = data
}
load(file, type) {
load(file, type, expires = 24 * 3600) {
let stat = fs.stat(file)
if (stat.isFile()) {
let size = stat.size
let _type = type || file.split('.').pop() || 'stream'
this.expires = 30 * 24 * 3600
this.expires = expires
this.type = _type
this.length = stat.size
return fs.origin.createReadStream(file).pipe(this.#res)

View File

@ -1,6 +1,6 @@
{
"name": "@gm5/response",
"version": "2.1.0",
"version": "2.1.1",
"type": "module",
"description": "对Http的response进一步封装, 提供常用的API",
"main": "index.js",