[Do Not Merge: Spike] => feat(performance): Add basic service-worker setup #14771
+1,346
−14
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.
The type of this PR is: Feat
This PR solves DIA-960
Description
This adds service worker ("Progressive Web App") support to Force via Google's Workbox plugin.
Some various docs:
Comparisons:
This is a big subject and there's room to debate whether this is truly valuable with the defaults out of the box, vs normal http caching. However, service workers are very powerful and feature-rich, and provide complete control over various things. So this wires up the functionality, and we can explore how this might benefit us.
They also support robust offline access -- that's what service-workers are typically used for -- with js assets that are pre-cached via webpack, so pages don't hard-error out at the asset level, but we still need to perform fetch for data. So again, questionable if this provides much value in Artsy's use-case. (Something like this would be very cool for Eigen tho -- if it were a web-app.)
Network responses can also be pushed into the cache. Here's a rough example:
I spiked on this many many years ago, but back then force was much more fragmented. Now that its unified, and we're on a performance kick, wanted to revisit and implement this as a spike, which is much easier due to site-wide consistency and Google's Webpack plugin.
@joeyAghion and @mzikherman - perhaps y'all can train your sharp thinking on this to see if there might be some yield? We can go deep here.
Some Screen-caps:
Example of first load, vs subsequent load:
service-worker.mp4
Example of offline not erroring out:
offline.mp4
cc @artsy/diamond-devs