workers-sdk
workers-sdk copied to clipboard
fix(pages-shared): Store asset key instead of body in preservation cache
Fixes # PAGES-2169
What this PR solves / how to test:
Stores assetKey in preservation cache rather than the actual asset so that we don't write rarely used bytes to cache. Also now only writes to cache once rather than on every request.
Tested in RC and ensured preservation cache still serves correctly
Author has addressed the following:
- Tests
- [x] Included
- [ ] Not necessary because:
- Changeset (Changeset guidelines)
- [x] Included
- [ ] Not necessary because:
- Associated docs
- [ ] Issue(s)/PR(s):
- [ ] Not necessary because:
🦋 Changeset detected
Latest commit: eb276d0e0f685c372de04abcaaabe057f076ae93
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| @cloudflare/pages-shared | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
A wrangler prerelease is available for testing. You can install this latest build in your project with:
npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8898342043/npm-package-wrangler-4797
You can reference the automatically updated head of this PR with:
npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/4797/npm-package-wrangler-4797
Or you can use npx with this latest build directly:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8898342043/npm-package-wrangler-4797 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8898342043/npm-package-create-cloudflare-4797 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8898342043/npm-package-cloudflare-kv-asset-handler-4797
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8898342043/npm-package-miniflare-4797
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8898342043/npm-package-cloudflare-pages-shared-4797
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/8898342043/npm-package-cloudflare-vitest-pool-workers-4797
Note that these links will no longer work once the GitHub Actions artifact expires.
[email protected] includes the following runtime dependencies:
| Package | Constraint | Resolved |
|---|---|---|
miniflare |
workspace:* | 3.20240419.0 |
workerd |
1.20240419.0 | 1.20240419.0 |
workerd --version |
1.20240419.0 | 2024-04-19 |
Please ensure constraints are pinned, and miniflare/workerd minor versions match.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 70.71%. Comparing base (
2789f26) to head (c77fdc0). Report is 74 commits behind head on main.
:exclamation: Current head c77fdc0 differs from pull request most recent head eb276d0. Consider uploading reports for the commit eb276d0 to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## main #4797 +/- ##
==========================================
- Coverage 72.44% 70.71% -1.74%
==========================================
Files 331 291 -40
Lines 17298 15164 -2134
Branches 4422 3859 -563
==========================================
- Hits 12532 10723 -1809
+ Misses 4766 4441 -325
@jahands - would you like to update with the suggestions given by @mrbbot before we merge this?
@jahands - do you have time to follow up on this PR?
@petebacondarwin We had internal issues blocking this and #4814 but we're finally back to working on these this week.
Great! Let me know when you are ready.
@petebacondarwin This should be good to go! I didn't do a great job rebasing and ended up force-pushing one big commit, but I called out the main fixup's that I did in addition to the feedback
Tested that the preservationCacheV1 (fallback) test passes without any of these changes, indicating that the V1 logic is preserved correctly
After thinking about it more, I realized that we want to periodically reset the Preservation cache expiration: https://github.com/cloudflare/workers-sdk/pull/4797/commits/3fad62d5874d7d1282153b7727079521cda063e4 Otherwise, it'll expire every week, which could cause issues in SPAs if someone deletes an asset right before the week is up.
Now I think this is done for reallll :)
Rebased for #5694 to fix the CI failure
(another rebase)