From 3c715be44490e50964ad126e77d452ee6c9f03f7 Mon Sep 17 00:00:00 2001 From: Siddharth Ganesan Date: Mon, 6 Jul 2026 18:49:01 -0700 Subject: [PATCH 1/2] fix(images): fix stale images --- .../files/components/file-viewer/image-preview.tsx | 6 +++++- apps/sim/next.config.ts | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/image-preview.tsx b/apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/image-preview.tsx index 0bac2180bed..e4ba8033261 100644 --- a/apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/image-preview.tsx +++ b/apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/image-preview.tsx @@ -7,7 +7,11 @@ import { ZoomablePreview } from './zoomable-preview' export const ImagePreview = memo(function ImagePreview({ file }: { file: WorkspaceFileRecord }) { const source = useFileContentSource() - const serveUrl = source.buildUrl(file.key) + // Version the URL on updatedAt: overwrites keep the same storage key, so an unversioned + // URL would resolve to a previously cached copy instead of the rewritten bytes. + const serveUrl = source.buildUrl(file.key, { + version: Number(new Date(file.updatedAt)) || file.size, + }) return ( diff --git a/apps/sim/next.config.ts b/apps/sim/next.config.ts index 1d42e1c7c22..bb53c72eba3 100644 --- a/apps/sim/next.config.ts +++ b/apps/sim/next.config.ts @@ -177,7 +177,12 @@ const nextConfig: NextConfig = { async headers() { return [ { - source: '/:all*(svg|jpg|jpeg|png|gif|ico|webp|avif|woff|woff2|ttf|eot)', + // Static assets only — the (?!api/) guard keeps this off API routes. Without it, + // /api/files/serve/.png matched too, and Next drops a route handler's own + // Cache-Control when the config rule already set one, so in-place file overwrites + // (same storage key, e.g. copilot image/chart regeneration) served day-stale bytes + // from the browser cache. + source: '/((?!api/).*\\.(?:svg|jpg|jpeg|png|gif|ico|webp|avif|woff|woff2|ttf|eot))', headers: [ { key: 'Cache-Control', From 88ea4b3c3e417da518dcc4a467df618c99f61cfc Mon Sep 17 00:00:00 2001 From: Siddharth Ganesan Date: Mon, 6 Jul 2026 18:50:52 -0700 Subject: [PATCH 2/2] Fix comment --- apps/sim/next.config.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/apps/sim/next.config.ts b/apps/sim/next.config.ts index bb53c72eba3..5f760789c4f 100644 --- a/apps/sim/next.config.ts +++ b/apps/sim/next.config.ts @@ -177,11 +177,6 @@ const nextConfig: NextConfig = { async headers() { return [ { - // Static assets only — the (?!api/) guard keeps this off API routes. Without it, - // /api/files/serve/.png matched too, and Next drops a route handler's own - // Cache-Control when the config rule already set one, so in-place file overwrites - // (same storage key, e.g. copilot image/chart regeneration) served day-stale bytes - // from the browser cache. source: '/((?!api/).*\\.(?:svg|jpg|jpeg|png|gif|ico|webp|avif|woff|woff2|ttf|eot))', headers: [ {