perf(web): cache macro images in local PWA, bump to 1.1.2
Same fix as the relay: the local PWA re-fetched every macro image and revoked the blob on each re-render. Cache image URL -> Promise<objectURL> and reuse across renders (images are immutable per uuid path); add Cache-Control: immutable on the desktop /api/image response. Verified in a browser: 7 re-renders produced only the initial 3 image fetches, none repeated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+5
-1
@@ -338,7 +338,11 @@ class WebServer:
|
||||
# Only serve files that resolve to inside the macro_images directory
|
||||
if (os.path.commonpath([requested, images_real]) == images_real
|
||||
and os.path.isfile(requested)):
|
||||
return FileResponse(requested)
|
||||
# Macro images are content-addressed (uuid filenames) and thus
|
||||
# immutable, so let the browser cache them aggressively.
|
||||
return FileResponse(requested, headers={
|
||||
"Cache-Control": "private, max-age=31536000, immutable"
|
||||
})
|
||||
raise HTTPException(status_code=404, detail="Image not found")
|
||||
|
||||
@app.websocket("/ws")
|
||||
|
||||
Reference in New Issue
Block a user