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

[Enhancement] HTTP/2 Server Push #685

Closed
exodus4d opened this issue Sep 14, 2018 · 1 comment
Closed

[Enhancement] HTTP/2 Server Push #685

exodus4d opened this issue Sep 14, 2018 · 1 comment
Assignees
Milestone

Comments

@exodus4d
Copy link
Owner

I want to speed up the initial page load/render time for the "login" and "/map" page. I want to take advantage of the new HTTP/2 Server Push feature vor Nginx (>= 1.13.9).

First of: If your installation does not fit the requirements, you will not see any different. If your Installation fits the requirements, users get a significant boot for the initial page load time.

Requirements:

  • HTTPS/2 active
  • http2_push_preload on; set in your Nginx server config

How it works:

  • Clients visiting your login page (initial page request) get pushed all static resources (CSS, JS, images,....) direct to the client without any additional HTTP request. Check the blogpost linked above.
@exodus4d exodus4d added this to the v1.4.1 milestone Sep 14, 2018
@exodus4d exodus4d self-assigned this Sep 14, 2018
@exodus4d exodus4d mentioned this issue Sep 17, 2018
@exodus4d
Copy link
Owner Author

Important: I forget to comment the issue with the current state. After implementation I got some questions about the usefulness of the ServerPush which led me to the decision to disable the ServerPush for v1.4.1.

Why?

  • Each user that visits the side, gets all resources pushed to, which are required to render the page and would be requested by the browser anyway -> Thats fine!
  • What about returning users? They would also receive Pushes for (CSS, JS,...) even if the browser has already cached them. So we would send additional 2MB of data to each returning client.... Think about mobile users with 3G connection -> Thats bad!
  • The only way to detect existing resources in browser cache would be a Cookie which is automatically send to the server (as described in the Nginx Blog). This requires more logic to be implemented.... What if browser cache was deleted and cookie information not? What should happen after a new release, cookie has to store the current version of the cached resources,...

So I want some answers to that questions before actually "enabling" ServerPush.

The good news:

  • The code written for ServerPush is still used and ServerPush can be tested by adding just one code line.
  • I wrote a Resource() PHP Class, that handles all resources for an endpoint . Resources can be registered to it and before the response it send to the client that Resource() class decides how to send the registered resources... There are two options
    1. Registered resources can be rendered as HTML preload tags <link rel="preload" .....> -> This is how it is used for now. Still faster than conventional loading but not as fast as ServerPush
    2. Registered resources can be send as ServerPush HTTP Headers, and Nginx sends the resources to the client

How it works`?

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

No branches or pull requests

1 participant