Skip to content
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

Use Service Workers (as grandchild of Gears) to bring back Turbo mode in admin #34

Closed
westonruter opened this issue Jul 13, 2018 · 2 comments · Fixed by #42
Closed

Use Service Workers (as grandchild of Gears) to bring back Turbo mode in admin #34

westonruter opened this issue Jul 13, 2018 · 2 comments · Fixed by #42
Assignees
Projects
Milestone

Comments

@westonruter
Copy link
Collaborator

westonruter commented Jul 13, 2018

Prior to WordPress 3.0 there was a "Turbo mode" in the WordPress admin which was used to cache scripts and stylesheets in the admin to speed up the experience. This Turbo mode depended on Google Gears. When Gears was discontinued the Turbo mode was also discontinued, and core switched to improving performance by concatenating scripts via load-scripts.php and load-styles.php. This has not been without problems, however. If there are too many scripts included then the URL could become too long in some browsers (though these browsers surely don't support service workers). Also this concatenation breaks the ability to reuse the cache for individual scripts. Google Gears was discontinued in favor of AppCache, and then AppCache has been deprecated in favor of Service Workers. The service worker is now capable of picking up the mantle of its grandfather Google Gears to bring back Turbo mode, and in a standardized way that does not require any browser plugins.

For history of Turbo mode, see:

For more, see WordPress Trac tickets mentioning “Gears” or “Turbo”.

@westonruter westonruter changed the title Investigate use of service worker to bring back Turbo mode I'm admin Investigate use of service worker to bring back Turbo mode in admin Jul 13, 2018
@westonruter westonruter changed the title Investigate use of service worker to bring back Turbo mode in admin Investigate use of Service Workers to bring back Turbo mode in admin Jul 13, 2018
@postphotos postphotos added this to Definition in Ongoing Jul 30, 2018
@westonruter westonruter changed the title Investigate use of Service Workers to bring back Turbo mode in admin Investigate use of Service Workers (as grandchild of Gears) to bring back Turbo mode in admin Jul 30, 2018
@miina miina self-assigned this Jul 30, 2018
@miina
Copy link
Contributor

miina commented Jul 31, 2018

Started looking into options for restoring the "Turbo" mode.

One option could be disabling concatenation of the scripts and styles by a filter and then adding Workbox strategy for caching all the assets. Created a PR to demo this approach with run-time caching: #42

Note that it might make sense to create PHP-level API for Workbox and leverage that for the Workbox strategy instead of using the JS directly, however, this doesn't exist yet so used direct JS as of now in the PR.

Also, perhaps it would be better to precache all the admin assets instead. In this case we would need to dynamically list all the asset files in relevant directories and use the list with workbox.precaching.precache([ LIST_OF_ASSETS ]).

Thoughts?

@miina miina moved this from Definition to In progress in Ongoing Jul 31, 2018
@westonruter
Copy link
Collaborator Author

@miina Good.

Note that it might make sense to create PHP-level API for Workbox and leverage that for the Workbox strategy instead of using the JS directly, however, this doesn't exist yet so used direct JS as of now in the PR.

Yes, now that you have the use case of Turbo mode in mind this will inform some use cases for what the PHP API supports.

Also, perhaps it would be better to precache all the admin assets instead. In this case we would need to dynamically list all the asset files in relevant directories and use the list with workbox.precaching.precache([ LIST_OF_ASSETS ]).

And yes, this is the intention behind installing the ADMIN service worker on the login screen. The idea is that the admin assets could precache while the user is logging in so that once they do get to the admin all of the assets are already primed in the cache.

This may not necessarily negate the use of runtime caching as well, however. There will be scripts and styles which are registered and enqueued dynamically for individual pages, and those could be included in the cache as well. This would allow caching assets from themes and plugins and not just core. Nevertheless we need to be careful about caching assets that are changing. For example, if developing a plugin and making changes to a script, you wouldn't want to have to manually bump the script's version every time you want to test changes. At the very least the cache should be disabled if SCRIPT_DEBUG is enabled. Maybe that is already the case for the Gears implementation.

I think this is particularly a problem for the runtime cache. If using precaching, however, we could potentially obtain a md5 hash of each script in the manifest and this would eliminate the concern about the asset ver not being updated.

@miina miina moved this from In progress to Ready for Review in Ongoing Aug 13, 2018
@westonruter westonruter changed the title Investigate use of Service Workers (as grandchild of Gears) to bring back Turbo mode in admin Use Service Workers (as grandchild of Gears) to bring back Turbo mode in admin Aug 15, 2018
@westonruter westonruter moved this from Ready for Review to In progress in Ongoing Aug 15, 2018
@postphotos postphotos added the Sprint 4 Sprint 4 label Sep 18, 2018
Ongoing automation moved this from In progress to Merged/Done Sep 27, 2018
@westonruter westonruter added this to the 0.2 milestone Apr 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Ongoing
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants