Skip to content

Commit

Permalink
Proxyキャッシュ7日
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Feb 18, 2024
1 parent 8104a5c commit c4aba35
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/server/file/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ router.get('/default-avatar.jpg', ctx => {
const file = fs.createReadStream(`${__dirname}/assets/avatar.jpg`);
ctx.body = file;
ctx.set('Content-Type', 'image/jpeg');
ctx.set('Cache-Control', 'max-age=2592000, s-maxage=172800, immutable');
ctx.set('Cache-Control', 'max-age=2592000, s-maxage=604800, immutable');
});

router.get('/app-default.jpg', ctx => {
const file = fs.createReadStream(`${__dirname}/assets/dummy.png`);
ctx.body = file;
ctx.set('Content-Type', 'image/jpeg');
ctx.set('Cache-Control', 'max-age=2592000, s-maxage=172800, immutable');
ctx.set('Cache-Control', 'max-age=2592000, s-maxage=604800, immutable');
});

router.get('/:id', sendDriveFile);
Expand Down
2 changes: 1 addition & 1 deletion src/server/file/send-drive-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ async function sendNormal(ctx: Router.RouterContext, body: Buffer | stream.Strea
return;
}
} else {
ctx.set('Cache-Control', 'max-age=2592000, s-maxage=172800, stale-while-revalidate=300, stale-if-error=86400, immutable');
ctx.set('Cache-Control', 'max-age=2592000, s-maxage=604800, stale-while-revalidate=300, stale-if-error=86400, immutable');
}

ctx.body = body;
Expand Down
2 changes: 1 addition & 1 deletion src/services/drive/add-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ async function upload(key: string, stream: fs.ReadStream | Buffer, type: string,
Key: key,
Body: stream,
ContentType: type,
CacheControl: 'max-age=2592000, s-maxage=172800, stale-while-revalidate=300, stale-if-error=86400, immutable',
CacheControl: 'max-age=2592000, s-maxage=604800, stale-while-revalidate=300, stale-if-error=86400, immutable',
} as PutObjectCommandInput;

if (filename) params.ContentDisposition = contentDisposition('inline', filename);
Expand Down

0 comments on commit c4aba35

Please sign in to comment.