From 2df5d68eaec753c6d87e2631fc737587e4b9a46d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Wed, 28 Feb 2024 15:26:36 +0100 Subject: [PATCH] Pass next.internal on fetch requests to avoid I/O sharing (#197) --- src/lib/cache/http.ts | 6 +++++- src/lib/images.ts | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/cache/http.ts b/src/lib/cache/http.ts index 1f3590c10..c6b764fcf 100644 --- a/src/lib/cache/http.ts +++ b/src/lib/cache/http.ts @@ -9,7 +9,11 @@ export const noCacheFetchOptions: Partial = { // Cloudflare doesn't support the `cache` directive before next-on-pages patches the fetch function // https://github.com/cloudflare/workerd/issues/698 // cache: 'no-store', - next: { revalidate: 0 }, + next: { + revalidate: 0, + // @ts-ignore - experiment to bypass potential I/O sharing in Next + internal: true, + }, }; /** diff --git a/src/lib/images.ts b/src/lib/images.ts index a3e1b2e77..2f65f0b18 100644 --- a/src/lib/images.ts +++ b/src/lib/images.ts @@ -1,5 +1,7 @@ import 'server-only'; +import { noCacheFetchOptions } from '@/lib/cache/http'; + import { rootUrl } from './links'; export interface CloudflareImageJsonFormat { @@ -147,6 +149,7 @@ export async function resizeImage( : `image/${resizeOptions.format || 'jpeg'}`, }, signal, + ...noCacheFetchOptions, }, );