Repository navigation
Conversation
|
related
Thanks for the PR @Akkii88 . I am not sure I will approve, need to discuss/think about it. In the meantime, can you please remove pnpm lock file from git? We use npm! Thank you again very much for contributing to Supabase! You're helping us make the tool better! 💚 |
📝 WalkthroughWalkthroughThe StorageFileApi.download method now merges a Cache-Control: no-store header with existing headers in its fetch request, preventing caching of downloaded files instead of sending only base headers. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi @Akkii88! Thank you for identifying this issue and proposing a fix. The problem you've identified is real, However, we can't merge this PR as-is because hardcoding
Better ApproachI've opened a new PR that takes a different approach: exposing fetch parameters rather than hardcoding headers. This allows Edge Function users to opt-in when needed: // Edge Functions - bypass cache
const { data } = await supabase.storage
.from('avatars')
.download('file.png', {}, { cache: 'no-store' })
// Default behavior (unchanged)
const { data } = await supabase.storage
.from('avatars')
.download('file.png')Thank you SO much for contributing to Supabase! Your PR actually helped me identify a problem and come up with a solution. Please do not be discouraged to contribute again in the future. Contributions like yours are what makes Supabase better! 💚 |
fix(storage): add no-store cache control to download
Description:
This Pull Request addresses an issue where the
storage.download()method would frequently return stale or cached data instead of the most recent version of a file. By explicitly adding theCache-Control: no-store headerto the download request, we ensure that the client always fetches the latest file content directly from the server, bypassing any intermediate caches.What changed?
I modified the
StorageFileApi.tsfile within the storage-js package. Specifically, I updated the downloadmethod to include the
Cache-Controlheader with a value ofno-storein the options object passed to the underlyinggetrequest function.Why was this change needed?
This change was necessary to resolve Issue #41841. Users reported that after updating a file in Supabase Storage, immediate subsequent calls to
_download()_would return the old file content. This behavior suggests that browsers or CDNs were serving a cached response. Adding no-store is a standard HTTP mechanism to instruct all caching layers to avoid storing the response, thereby guaranteeing that the application receives the most up-to-date data.Breaking changes This Pull Request contains no breaking changes. It only modifies internal header logic for the download request and does not alter the public API signature or return types.
Summary by CodeRabbit