This repository has been archived by the owner on Aug 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 334
fix: expire unused assets on site upload #2221
Merged
Merged
Conversation
This file contains 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
currently, we just delete unused assets when uploading a new version of a workers-sites project. this can cause problems when a user accessing an old site gets a 404 when going to a page when the new assets haven't been pushed out to the edge yet, but the old assets have already been deleted. this commit addresses this by marking old assets for expiration in five minutes, rather than deleting them outright. this should give the new worker enough time to propogate to the edge before the old assets are taken down.
jspspike
approved these changes
Mar 17, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and seems to work as intended.
@jgentes This change might make publish take a lot longer. Maybe for the future we should make a bulk endpoint to get a set of values with a set of keys so each key doesn't have a request.
// isn't this very slow? yes. can we do this in bulk? unfortunately as of now | ||
// there isn't a KV endpoint for "bulk read". | ||
// https://api.cloudflare.com/#workers-kv-namespace-properties | ||
let five_minutes_from_now = chrono::Utc::now().timestamp() + (60 * 5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Maybe use the duration struct in chrono for 5 minutes
Looks like this is breaking people's deploys #2224 We should fix this asap. I'll work on a solution for w2 myself. |
I posted cloudflare/workers-sdk#649 for w2 |
caass
pushed a commit
that referenced
this pull request
Mar 22, 2022
This was referenced May 31, 2023
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
backport of cloudflare/workers-sdk#587
currently, we just delete unused assets when uploading a new version
of a workers-sites project. this can cause problems when a user
accessing an old site gets a 404 when going to a page when the new
assets haven't been pushed out to the edge yet, but the old assets have
already been deleted.
this commit addresses this by marking old assets for expiration
in five minutes, rather than deleting them outright. this should give
the new worker enough time to propogate to the edge before the old
assets are taken down.