File tree Expand file tree Collapse file tree
app/workspace/[workspaceId]/files/components/file-viewer Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,7 +7,11 @@ import { ZoomablePreview } from './zoomable-preview'
77
88export const ImagePreview = memo ( function ImagePreview ( { file } : { file : WorkspaceFileRecord } ) {
99 const source = useFileContentSource ( )
10- const serveUrl = source . buildUrl ( file . key )
10+ // Version the URL on updatedAt: overwrites keep the same storage key, so an unversioned
11+ // URL would resolve to a previously cached copy instead of the rewritten bytes.
12+ const serveUrl = source . buildUrl ( file . key , {
13+ version : Number ( new Date ( file . updatedAt ) ) || file . size ,
14+ } )
1115
1216 return (
1317 < ZoomablePreview className = 'flex flex-1' contentClassName = 'h-full w-full' >
Original file line number Diff line number Diff line change @@ -177,7 +177,12 @@ const nextConfig: NextConfig = {
177177 async headers ( ) {
178178 return [
179179 {
180- source : '/:all*(svg|jpg|jpeg|png|gif|ico|webp|avif|woff|woff2|ttf|eot)' ,
180+ // Static assets only — the (?!api/) guard keeps this off API routes. Without it,
181+ // /api/files/serve/<key>.png matched too, and Next drops a route handler's own
182+ // Cache-Control when the config rule already set one, so in-place file overwrites
183+ // (same storage key, e.g. copilot image/chart regeneration) served day-stale bytes
184+ // from the browser cache.
185+ source : '/((?!api/).*\\.(?:svg|jpg|jpeg|png|gif|ico|webp|avif|woff|woff2|ttf|eot))' ,
181186 headers : [
182187 {
183188 key : 'Cache-Control' ,
You can’t perform that action at this time.
0 commit comments