-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
chore: Prefetch consolidated api using service worker #33306
Merged
Merged
Changes from 5 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
e0cacf1
WIP
dvj1988 c748784
WIP 2
dvj1988 ae3afec
WIP 3
dvj1988 38eba74
Add view url
dvj1988 74964a8
Move service worker to dev config
dvj1988 f985f17
Merge remote-tracking branch 'origin' into chore/prefetch-consolidate…
dvj1988 2cfc7e7
Add url origin to the prefetching logic
dvj1988 0ab583f
Revert changes in craco common
dvj1988 dd9f8e6
Revert a change in serviceWorker
dvj1988 5d27434
Make changes to invalidate current bundle
dvj1988 90580be
Interim change
dvj1988 411c77a
Reset the cache on first fetch
dvj1988 c32a137
Merge remote-tracking branch 'origin' into chore/prefetch-consolidate…
dvj1988 4d9c7b2
Refactor code to handle git applications also
dvj1988 3bf22d7
Move methods to a util fn
dvj1988 094de9d
Add test cases
dvj1988 ff376d6
Revert unnecessary changes
dvj1988 b9f1ab5
PR comments
dvj1988 02967d5
Refactor and update test cases
dvj1988 cf64171
Remove caching of files indev mode of service worker
dvj1988 2e6f9b5
Add version number to cache name
dvj1988 7284f81
Implement skip cache
dvj1988 9300be7
Final checks and test cases
dvj1988 72e079f
Fix a typo
dvj1988 feae9fa
Add comments
dvj1988 7c6ab9d
Add cache expiry
dvj1988 ae9aa5b
PR comments
dvj1988 cd75730
PR comments
dvj1988 7cb6ea6
Add comments and change variable name
dvj1988 a32c11f
Implement the logic with mutex
dvj1988 ceaf254
refactor
dvj1988 016c983
Update test cases
dvj1988 4024a6f
Remove logs and add comments
dvj1988 d06f4d9
Rename describe block
dvj1988 17b6d45
PR comments
dvj1988 30e2db9
Add catch block to main request handler
dvj1988 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
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
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
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
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.
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.
Revert this. This change is required only for testing
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.
Does this change need to be reverted ?
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.
We can leave it as is and enable it for dev mode.
Just FYI there are some warnings that popup in the terminal as result of enabling WorkboxPlugin in dev mode. This is a known issue for webpack watch mode (InjectManifest has been called multiple times, perhaps due to running webpack in --watch mode.)
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.
@dvj1988 Does it affect the build time somehow? Did you check it?
We have some issues with building time, if it is not necessary, then I would prefer not to add anything here.
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.
I have not seen any issues with the dev server build time or hot reloads. Preferably we want to keep this so that we have the same behaviour of the service worker in the dev and prod modes.
Earlier we were using service worker to cache the static assets but this PR is prefetching and caching one of the apis. If there are any main bundle changes that would affect the behaviour of the service worker or vice versa we want to start catching them in the dev mode itself.
After the merge I will keep a track of whether this is affecting any devs local setup and can take a measure accordingly.
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.
@KelvinOm Do you have any specific scenario in mind to test?
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.
@dvj1988 I am most interested in the start time (with and without cache) and the recompilation time. We also have problems OOM issues, this should not make the situation worse.
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.
@KelvinOm By cache do you mean lint cache?
How do you propose I measure these?
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.
By cache I mean
babel-loader
cache it stored atapp/client/node_modules/.cache/babel-loader
. It is created when the webpack is running.I do not know a good way to do this. I'm measuring the time in terminal. We can use
time
liketime yarn start
. I couldn't run the webpack speed measure plugin because it doesn't work withcraco
. So we have to measure it manually.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.
@KelvinOm I used the package called
gnomon
. And the time taken looks the same.Start time without cache was replicated by following the steps
yarn start | gnomon --type=elapsed-total
Tests done in: Apple M1 Pro, RAM 32 GB
Start time without cache - release
![Screenshot 2024-05-16 at 4 44 52 PM](https://private-user-images.githubusercontent.com/18716465/331197798-55ba6081-d6f5-4115-b7f2-4f5a84f7f0df.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkyNDUxMDYsIm5iZiI6MTcxOTI0NDgwNiwicGF0aCI6Ii8xODcxNjQ2NS8zMzExOTc3OTgtNTViYTYwODEtZDZmNS00MTE1LWI3ZjItNGY1YTg0ZjdmMGRmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI0VDE2MDAwNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWY3MjU4ZjU0MWY2NTVkYTE3YjNkZDE1M2I5MjA2OWZkZWVmMDI1YjIxYTlmNDVlMjhkYTYyYTIyYzc1NWZiYWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.jyMYwQRQSmGtxM1UknjvX8MhkC64FB2jh9zqs_BDEig)
![Screenshot 2024-05-16 at 4 47 10 PM](https://private-user-images.githubusercontent.com/18716465/331197816-831a16a8-b9c6-4b3c-8028-5b4c5d884b62.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkyNDUxMDYsIm5iZiI6MTcxOTI0NDgwNiwicGF0aCI6Ii8xODcxNjQ2NS8zMzExOTc4MTYtODMxYTE2YTgtYjljNi00YjNjLTgwMjgtNWI0YzVkODg0YjYyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI0VDE2MDAwNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWVmYzQ5N2UzYTAwZTMxZWMxNGNmNzcwYTcwODU4ODEyZjRlY2I3MWEzZGVmOGNhM2FjNTk3MDAxNmYyYTQ4ZjQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.lL6tSCyGX8iHmbH21TZR65_h0M-Fo00ahnBJgYd_2I4)
![Screenshot 2024-05-16 at 5 39 47 PM](https://private-user-images.githubusercontent.com/18716465/331197825-99559083-f420-4a2d-bb37-5c8212d18219.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkyNDUxMDYsIm5iZiI6MTcxOTI0NDgwNiwicGF0aCI6Ii8xODcxNjQ2NS8zMzExOTc4MjUtOTk1NTkwODMtZjQyMC00YTJkLWJiMzctNWM4MjEyZDE4MjE5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI0VDE2MDAwNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQzMGQ2ZGU5Mjg4OTU2ZWIyMmZkOGFhYzBiOGMwM2IyNmNkZDBjYWU2OTg2MjU4OTUwNmMwYjNkZDUwOWI5ZjEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.f28Vyc7OL_CVmoLHNLBN1JNdkQkTmcMatzznQA0EU4Y)
![Screenshot 2024-05-16 at 5 12 39 PM](https://private-user-images.githubusercontent.com/18716465/331198534-a75e75c3-cc6e-4146-a30d-de3d55bcb63c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkyNDUxMDYsIm5iZiI6MTcxOTI0NDgwNiwicGF0aCI6Ii8xODcxNjQ2NS8zMzExOTg1MzQtYTc1ZTc1YzMtY2M2ZS00MTQ2LWEzMGQtZGUzZDU1YmNiNjNjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjI0VDE2MDAwNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWUzODkwZWVlOTRiMDNhZWJhYWZlYjJjOGNkMThjMWRlZDMwMTU2MGI5NTZkMjg5MTVhMGU2ZTk0NTViNDZlMTUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.04-2sDBgzIohaFxXvbhjKglomD-pxBHjupQJhlDlj8Q)
Start time with cache - release
Start time without cache - chore/prefetch-consolidated-api
Start time with cache - chore/prefetch-consolidated-api