-
Notifications
You must be signed in to change notification settings - Fork 78
feat(cloudflare): add optional R2 batch uploads via rclone for cache population #925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vicb
merged 23 commits into
opennextjs:main
from
dev-kisuyw-next:batch-cache-files-upload-using-rclone
Oct 14, 2025
Merged
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
d8171c5
feat: add --rcloneBatch flag for faster R2 cache uploads using rclone
5aefc21
fix(test): remove useless test
c79d18d
test: add tests for populateCache with R2 cache
d0c5606
commit to trigger pkg-pr-new action
15a874f
refactor: not expose rclone to user and use batch upload based on env…
0d53eac
test: update populateCache tests after implementation changes
3d181e5
fix: enhance error handling in populateCache for rclone uploads
32dc294
docs: add links for creating R2 access API tokens in README
a473d6e
fix: update environment variable references from R2_ACCOUNT_ID to CLO…
fe8f553
feat: add support for loading environment variables from .env file
bdf3f92
fix: update environment variable references from CLOUDFLARE_ACCOUNT_I…
de25a0b
fix: refactor R2 cache population to always try batch uploads before …
4740a48
Merge branch 'main' of github.com:krzysztof-palka-monogo/opennextjs-c…
c11df41
fix: use temporary directory for staging cache upload
09a8d9e
fix: use batch cache upload only for remote R2
4f93b83
fix: update documentation to specify .env file usage
5b94213
fix: clarify CF_ACCOUNT_ID comment for skew protection and R2 batch p…
a25b5cd
fix: cleanup envs setup
a0b1361
Apply suggestion from @vicb
vicb 6f2c916
fix: remove load-envs
bd2239f
fix: use rclone.js package instead of rclone directly
2a3ecff
fix: update rclone.js import to use default export
3ec1364
fix: run linter
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| --- | ||
| "@opennextjs/cloudflare": minor | ||
| --- | ||
|
|
||
| feature: optional batch upload for faster R2 cache population | ||
|
|
||
| This update adds optional batch upload support for R2 cache population, significantly improving upload performance for large caches when enabled via .env or environment variables. | ||
|
|
||
| **Key Changes:** | ||
|
|
||
| 1. **Optional Batch Upload**: Configure R2 credentials via .env or environment variables to enable faster batch uploads: | ||
|
|
||
| - `R2_ACCESS_KEY_ID` | ||
| - `R2_SECRET_ACCESS_KEY` | ||
| - `CF_ACCOUNT_ID` | ||
|
|
||
| 2. **Automatic Detection**: When credentials are detected, batch upload is automatically used for better performance | ||
|
|
||
| 3. **Smart Fallback**: If credentials are not configured, the CLI falls back to standard Wrangler uploads with a helpful message about enabling batch upload for better performance | ||
|
|
||
| **All deployment commands support batch upload:** | ||
|
|
||
| - `populateCache` - Explicit cache population | ||
| - `deploy` - Deploy with cache population | ||
| - `upload` - Upload version with cache population | ||
| - `preview` - Preview with cache population | ||
|
|
||
| **Performance Benefits (when batch upload is enabled):** | ||
|
|
||
| - Parallel transfer capabilities (32 concurrent transfers) | ||
| - Significantly faster for large caches | ||
| - Reduced API calls to Cloudflare | ||
|
|
||
| **Usage:** | ||
|
|
||
| Add the credentials in a `.env`/`.dev.vars` file in your project root: | ||
|
|
||
| ```bash | ||
| R2_ACCESS_KEY_ID=your_key | ||
| R2_SECRET_ACCESS_KEY=your_secret | ||
| CF_ACCOUNT_ID=your_account | ||
| ``` | ||
|
|
||
| You can also set the environment variables for CI builds. | ||
|
|
||
| **Note:** | ||
|
|
||
| You can follow documentation https://developers.cloudflare.com/r2/api/tokens/ for creating API tokens with appropriate permissions for R2 access. |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.