-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat: LSDV-4972: Optimize the requests for presigning urls #4106
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
…dically to ensure the storage is not flooded
✅ Deploy Preview for label-studio-docs-new-theme canceled.
|
✅ Deploy Preview for heartex-docs canceled.
|
hlomzik
approved these changes
May 2, 2023
vladimirheartex
approved these changes
May 5, 2023
shayantabatabaee
pushed a commit
to shayantabatabaee/label-studio
that referenced
this pull request
Sep 19, 2023
…al#4106) * feat: LSDV-4972: Optimize the requests for presigning urls * cache the redirect responses only, and set to cleanup the cache periodically to ensure the storage is not flooded * leave the sw-inert empty in the fetch, so network is used entirely untouched * linting * ci: Build frontend * update sw comments and name of inert to fallback * inlining Date.now to the expiration check * ci: Build frontend --------- Co-authored-by: robot-ci-heartex <robot-ci-heartex@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR fulfills these requirements
[fix|feat|ci|chore|doc]: TICKET-ID: Short description of change made
ex.fix: DEV-XXXX: Removed inconsistent code usage causing intermittent errors
Change has impacts in these area(s)
(check all that apply)
Describe the reason for change
The introduction of the presigned url proxy approach allows for consistent, secure and transparent handling of all task data so the client can safely use the urls embedded in the JSON response without it expiring. This works great for most of the requests made from the application, except for image requests. Image requests are not able to properly cache the response and therefore will always re-request the presigned url endpoint which burdens the server.
What does this fix?
Here we are intercepting the requests made to presign, with a service worker, and cache only the redirect response (not the final response body!) so that the browser can effectively use its own heuristics on the resources presigned url, caching the actual response either in disk/memory cache. This reduces the amounts of requests that hit the server by an order of magnitude, while ensuring the requests are still valid and not being made to an expired presigned url. Because of the way in which Media elements request data, we are skipping Range requests here as there is no need to cache these redirects since it will be making the subsequent requests to the presigned url directly, and not the internal proxy redirect url, and has handling already for recovering from and refreshing presigned urls through the proxy.
What libraries were added/updated?
None.
Does this change affect performance?
Improves performance by removing a pile of redundant requests and making the natural browser cache effective once more.
Does this change affect security?
This is more secure as the only aspect of which is cached is the presigned url which the request would be redirected to, after it is checked fully against the user on the server. This means the url which is user facing is always valid, and never stale, but remains secure at all times.
What alternative approaches were there?
What feature flags were used to cover this change?
fflag_fix_all_lsdv_4711_cors_errors_accessing_task_data_short
Does this PR introduce a breaking change?
(check only one)
What level of testing was included in the change?
(check all that apply)
Which logical domain(s) does this change affect?
Presigned Urls.