Skip to content

[blob] feat: add useCache option to bypass CDN cache#954

Merged
vvo merged 6 commits intoblob/privatefrom
vvo/blob-cache-bypass
Jan 29, 2026
Merged

[blob] feat: add useCache option to bypass CDN cache#954
vvo merged 6 commits intoblob/privatefrom
vvo/blob-cache-bypass

Conversation

@vvo
Copy link
Copy Markdown
Member

@vvo vvo commented Jan 27, 2026

Summary

Adds a useCache option to blob.get() that controls whether to fetch from CDN cache or directly from origin storage:

  • useCache: true (default) - allows blob to be served from CDN cache
  • useCache: false - fetches directly from origin storage

Note: Only effective for private blobs. Public blobs always use CDN cache.

Why

This is useful when you need the latest version of a blob immediately after an update, bypassing any cached responses.

Usage

const { stream, blob } = await get('my-file.txt', {
  access: 'private',
  useCache: false, // fetch directly from origin
});

Test plan

  • Added tests for useCache: false appending ?cache=0
  • Added tests for useCache: true and omitted not appending query param
  • Added tests verifying returned downloadUrl doesn't include cache=0
  • All SDK tests passing

🤖 Generated with Claude Code

Add a `useCache` option to `blob.get()` that controls whether to use
the content-cache layer:
- `useCache: true` (default) = normal caching behavior
- `useCache: false` = appends ?cache=0 to bypass cache

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jan 27, 2026

⚠️ No Changeset found

Latest commit: e121acd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Jan 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
vercel-storage-next-integration-test-suite Ready Ready Preview Jan 28, 2026 4:58pm

Request Review

Comment thread packages/blob/src/get.ts Outdated
@vvo vvo changed the title [blob] feat: add useCache option to bypass content-cache [blob] feat: add useCache option to bypass CDN cache Jan 28, 2026
@vvo vvo marked this pull request as ready for review January 29, 2026 16:57
@vvo vvo merged commit 4adc7b7 into blob/private Jan 29, 2026
2 checks passed
@vvo vvo deleted the vvo/blob-cache-bypass branch January 29, 2026 16:57
vvo added a commit that referenced this pull request Feb 19, 2026
* [blob] add private blobs

* browser

* changeset

* bypass

* latest

* main

* remove live tests

* multi part tests

* add get by blob

* update blob with streams

* add access type

* allow download urls and simplify typing

* update

* update

* feat(blob): add raw headers to get() response

Add headers property to GetBlobResult interface, returning the raw
Headers object from the fetch response for accessing additional
metadata like ETag or x-vercel-* headers.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(blob): add optional headers option to get()

Allow passing additional headers to the fetch request via an optional
headers option. Documented as an advanced feature since most users
won't need it. The authorization header is always set automatically.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* ensure createFolder requires access property now, it's a write like put

* [blob] feat: add useCache option to bypass CDN cache (#954)

* [blob] feat: add useCache option to bypass content-cache

Add a `useCache` option to `blob.get()` that controls whether to use
the content-cache layer:
- `useCache: true` (default) = normal caching behavior
- `useCache: false` = appends ?cache=0 to bypass cache

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: clarify useCache only works for private blobs

* Apply suggestion from @vvo

* docs: use opaque terminology for cache (edge cache vs origin storage)

* docs: use CDN cache terminology

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

* add tests for private, fix method

* update

* update

* fix(blob): add etag to get() response

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* update

* update

* update ts docs

* conditional gets

* add conditional reads

* changeset

* update

---------

Co-authored-by: Shawn Feldman <shawn.feldman@vercel.com>
Co-authored-by: Vincent Voyer <vincent@codeagain.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
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.

1 participant