fix(storage): s3 based images not using browser cache - #151
Open
thezak48 wants to merge 4 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a per-process, thread-safe in-memory cache for S3 presigned image URLs in storage.py, aiming to reduce repeated S3 calls and keep redirect URLs stable within their TTL.
Changes:
- Added a global presigned-URL cache with locking and expiry handling.
- Updated
get_presigned_image_url()to return cached URLs when still valid and cache newly generated URLs. - Evicted cached entries when uploads overwrite assets or when comparison assets are deleted.
thezak48
force-pushed
the
fix/s3-cache
branch
2 times, most recently
from
July 12, 2026 11:10
f96103e to
5dda750
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This pull request adds an in-memory caching layer for S3 presigned URLs in
storage.pyto improve performance and reduce unnecessary S3 calls. The cache is thread-safe, supports eviction on asset changes, and ensures URLs are refreshed before expiration. The main changes are grouped below:Presigned URL Caching:
_presigned_url_cache) for S3 presigned URLs, including logic to store, retrieve, and evict cached URLs with expiration handling. [1] [2] [3]get_presigned_image_urlto use the cache, returning a cached URL if available and valid, and caching new URLs after generation.Cache Invalidation:
save_upload_fileanddelete_comparison_assetsto ensure the cache remains consistent when assets are added or deleted. [1] [2]