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

Intent to unship: support for streaming responses #191

Closed
westonruter opened this issue Jul 8, 2019 · 1 comment · Fixed by #215
Closed

Intent to unship: support for streaming responses #191

westonruter opened this issue Jul 8, 2019 · 1 comment · Fixed by #215
Milestone

Comments

@westonruter
Copy link
Collaborator

The PWA plugin includes support for streaming responses. This allows for a header to be pre-cached with the body and footer then being combined in the response. The result is that a user should perceive a faster loading experience. For all the details and a demo video, see #85.

The support for streaming responses in WordPress was really a proof of concept to show that it could be done. But there are some key challenges that limit its applicability:

  1. Since the header is pre-cached, the requested body needs to included additional logic to modify the head as required. For example, it has to update the document.title, sync meta tags, update stylesheets, and so on. Some of these aren't as much of a problem when AMP is involved because all scripts are asynchronous and AMP web components are being used, but the AMP plugin had to be specifically built to support this (Add service worker streaming for AMP documents ampproject/amp-wp#1503). For a non-AMP page, a big challenge would be scripts in the head which would need to be replaced/removed from the precached header. Assuming the precached header includes the site nav menu, then the body response also has to do the work of synchronizing nav menu item classes.
  2. Response headers sent in a navigation request are not processed by the browser. For example, if making a request to ?p=123 intending to redirect to the permalink, this will not just work because the body response is streamed after the precached header was already rendered. This would mean all logic for handling response headers (e.g. Location) would need to be replicated in JS.
  3. Streaming responses works well when the header does not change from page to page. This is definitely not the case in WordPress, since get_header() includes output for a lot of page-specific markup, including styles, title, metadata, body classes, nav menu item classes, etc.

All this being said, adding support for streaming responses in WordPress was interesting, but it doesn't seem widely applicable, especially not for the 80%. And thus it should be removed.

@westonruter westonruter added this to the 0.3 milestone Jul 8, 2019
@westonruter westonruter modified the milestones: 0.3, 0.4 Jul 29, 2019
@amedina
Copy link
Collaborator

amedina commented Aug 11, 2019

This is a correct assessment. While it was an interesting and important exercise, and it may be made available in the future, it should not be part of the foundational aspects of an integration of PWA capabilities into WordPress core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants