From 815d12e137b7357ff63d03f57a9ff89a6297fa93 Mon Sep 17 00:00:00 2001 From: Yufan Sheng Date: Wed, 26 Jun 2024 23:03:03 +0800 Subject: [PATCH] chore: add cache to avatar proxy header. --- package-lock.json | 86 +++------------------------------- package.json | 2 +- src/pages/avatar/[hash].png.ts | 5 +- 3 files changed, 12 insertions(+), 81 deletions(-) diff --git a/package-lock.json b/package-lock.json index 31e35ed..69a17b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@astrojs/mdx": "^3.1.2", "@astrojs/node": "^8.3.2", "@astrojs/rss": "^4.0.7", - "astro": "^4.11.1", + "astro": "^4.11.3", "drizzle-orm": "^0.31.2", "fuse.js": "^7.0.0", "lodash": "^4.17.21", @@ -4417,9 +4417,9 @@ } }, "node_modules/astro": { - "version": "4.11.1", - "resolved": "https://registry.npmjs.org/astro/-/astro-4.11.1.tgz", - "integrity": "sha512-6e9/9nafmnxzaLSq2+9VNpi+7j0E4UoK2IJ7gkhyv1wk3XfciA6zHc3ESx7/Sk/rjenz9NSTTzAwcmVzWWHv/g==", + "version": "4.11.3", + "resolved": "https://registry.npmjs.org/astro/-/astro-4.11.3.tgz", + "integrity": "sha512-SuZbB/71XVn+WqWNCe7XOfHuqhS+k4gj8+A3wluTZQrORGaHUFRn/f8F9Tu5yESQZB1q8UKhahvHwkTV3AdVsg==", "license": "MIT", "dependencies": { "@astrojs/compiler": "^2.8.1", @@ -4471,7 +4471,6 @@ "preferred-pm": "^3.1.3", "prompts": "^2.4.2", "rehype": "^13.0.1", - "resolve": "^1.22.8", "semver": "^7.6.2", "shiki": "^1.9.0", "string-width": "^7.1.0", @@ -4707,9 +4706,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001636", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001636.tgz", - "integrity": "sha512-bMg2vmr8XBsbL6Lr0UHXy/21m84FTxDLWn2FSqMd5PrlbMxwJlQnC2YWYxVgp66PZE+BBNF2jYQUBKCo1FDeZg==", + "version": "1.0.30001637", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001637.tgz", + "integrity": "sha512-1x0qRI1mD1o9e+7mBI7XtzFAP4XszbHaVWsMiGbSPLYekKTJF7K+FNk6AsXH4sUpc+qrsI3pVgf1Jdl/uGkuSQ==", "funding": [ { "type": "opencollective", @@ -5782,15 +5781,6 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/function-bind": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", - "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/fuse.js": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-7.0.0.tgz", @@ -5946,18 +5936,6 @@ "node": ">=4" } }, - "node_modules/hasown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", - "license": "MIT", - "dependencies": { - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/hast-util-from-html": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/hast-util-from-html/-/hast-util-from-html-2.0.1.tgz", @@ -6331,21 +6309,6 @@ "node": ">=8" } }, - "node_modules/is-core-module": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.14.0.tgz", - "integrity": "sha512-a5dFJih5ZLYlRtDc0dZWP7RiKr6xIKzmn/oAYCDvdLThadVgyJwlaoQPmRtMSpz+rk0OGAgIu+TcM9HUF0fk1A==", - "license": "MIT", - "dependencies": { - "hasown": "^2.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-decimal": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-2.0.1.tgz", @@ -8252,12 +8215,6 @@ "node": ">=8" } }, - "node_modules/path-parse": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "license": "MIT" - }, "node_modules/path-scurry": { "version": "1.11.1", "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", @@ -9035,23 +8992,6 @@ "integrity": "sha512-e+3wwdki9elemYP6AnyG2BK9/Gd7ak46wZN+Z62WwmWfhn2La1XV2rPRRIcar+PhRhfiQDXi29TapGMTIbI3Pg==", "dev": true }, - "node_modules/resolve": { - "version": "1.22.8", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", - "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", - "license": "MIT", - "dependencies": { - "is-core-module": "^2.13.0", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - }, - "bin": { - "resolve": "bin/resolve" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/restore-cursor": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-4.0.0.tgz", @@ -9710,18 +9650,6 @@ "node": ">=4" } }, - "node_modules/supports-preserve-symlinks-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", diff --git a/package.json b/package.json index f3d35b1..65d4a7d 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@astrojs/mdx": "^3.1.2", "@astrojs/node": "^8.3.2", "@astrojs/rss": "^4.0.7", - "astro": "^4.11.1", + "astro": "^4.11.3", "drizzle-orm": "^0.31.2", "fuse.js": "^7.0.0", "lodash": "^4.17.21", diff --git a/src/pages/avatar/[hash].png.ts b/src/pages/avatar/[hash].png.ts index ad8ccf1..3aff4e5 100644 --- a/src/pages/avatar/[hash].png.ts +++ b/src/pages/avatar/[hash].png.ts @@ -27,7 +27,10 @@ const avatarImage = async ( } return new Response(Buffer.from(await resp.arrayBuffer()), { - headers: { 'Content-Type': 'image/png' }, + headers: { + 'Content-Type': 'image/png', + 'Cache-control': 'max-age=604800', + }, }); };