From 1b85665b90896be68261cbf405f80d464972d387 Mon Sep 17 00:00:00 2001 From: Matteo Manfredi Date: Wed, 6 Sep 2023 00:39:41 +0200 Subject: [PATCH] fix: fix remote `astro:assets` caching logic --- .changeset/empty-rings-bow.md | 5 +++++ packages/astro/src/assets/build/generate.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/empty-rings-bow.md diff --git a/.changeset/empty-rings-bow.md b/.changeset/empty-rings-bow.md new file mode 100644 index 000000000000..fd928d548c04 --- /dev/null +++ b/.changeset/empty-rings-bow.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes remote assets caching logic to not use expired assets diff --git a/packages/astro/src/assets/build/generate.ts b/packages/astro/src/assets/build/generate.ts index b2004fad01c8..71903e9945fe 100644 --- a/packages/astro/src/assets/build/generate.ts +++ b/packages/astro/src/assets/build/generate.ts @@ -75,7 +75,7 @@ export async function generateImage( const JSONData = JSON.parse(readFileSync(cachedFileURL, 'utf-8')) as RemoteCacheEntry; // If the cache entry is not expired, use it - if (JSONData.expires < Date.now()) { + if (JSONData.expires > Date.now()) { await fs.promises.writeFile(finalFileURL, Buffer.from(JSONData.data, 'base64')); return {