Skip to content

Cache the contents of an uploaded SVG icon - #8

Merged
jdbg merged 1 commit into
mainfrom
cache-uploaded-icon-markup
Sep 20, 2026
Merged

jdbg merged 1 commit into
mainfrom
cache-uploaded-icon-markup

Conversation

@tomjn

@tomjn tomjn commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

An uploaded icon was read from disk on every render. With uploads in remote storage such as S3 Uploads, that is a network request per icon button per uncached page view.

The entry is keyed on the attachment's modified time and has no expiry, so there was no TTL to guess at. The tradeoff is that a file replaced in place, with nothing updating the attachment, keeps serving the old contents until the cache is flushed. SECURITY.md covers what that means for sanitising a file that is already uploaded.

uploaded_icon_markup() read the file on every render. Where uploads are in remote storage such as S3 Uploads, that is a network request per icon button per uncached page view.

The entry is keyed on the attachment's modified time and has no expiry, so there is no TTL to pick and updating the attachment retires it. Only the file contents are cached, so one entry serves every size.
@jdbg
jdbg merged commit 18b0de6 into main Sep 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants