Jump to content

HTTP/2 Push


adrian
 Share

Recommended Posts

Hi all - I just wanted to start a discussion about using push with http/2. @teppo's recent post here (https://processwire.com/talk/topic/5630-module-aiom-all-in-one-minify-for-css-less-js-and-html/?do=findComment&comment=193086) got me to finally move all my servers to use http/2 which is great, but it seems like there is much more to it than that.

There are a few articles of interest: 

https://www.smashingmagazine.com/2017/04/guide-http2-server-push/ 
https://www.keycdn.com/blog/http-preload-vs-http2-push
https://jakearchibald.com/2017/h2-push-tougher-than-i-thought/

but I'd love to hear what everyone is actually doing on their sites and also wondering if the PW core should try to push certain assets.

There seem to be issues with browsers not caching assets when push is used and I am wondering whether in general you should push everything needed for a page, or ?

Thanks all!

PS - if you're wanting to upgrade your Debian or Ubuntu servers, this is a good guide: https://blog.samuel.domains/blog/tutorials/how-to-enable-http2-on-apache-debian-9 - I am running Debian 10 and PHP 7.3 so just replace the references to 7.0 to 7.3 and you'll be good.

  • Like 4
Link to comment
Share on other sites

4 hours ago, wbmnfktr said:

It's just my experience but... a lot of hosting companies here don't have http/2 enabled in their default/smaller webhosting plans. Therefore I rarely think about the benefits of http/2. ? 

Yep, but it definetly will change at those smaller webhosting plans too, at least if they are setup using ubuntu etc., because (I heard from a medium german hosting company) that upcoming ubuntu etc. will change apache's default setup to work with HTTP/2 (and PHP as apache module is dropped and no more available then ? ).

Link to comment
Share on other sites

http/2 + brotil ??. I use runcloud for clients and now apnscp panel for my server, and both do h2 + br out of the box.

I still bundle everything tho since not doing so would involve not using any build system which seem crazy to me, plus after first load things should be cached by the browser so it makes no difference whatsoever after that. Realistically images take up much more space and IMO focus should be given to optimising them as much as possible.

Link to comment
Share on other sites

I know phoenix - the elixir framework I use nowadays - removed it's high level helpers for server push before it's last release, because something about the caching of pushed assets wasn't up to what they wanted it to be: https://github.com/phoenixframework/phoenix/issues/2875. I'm not sure if the situation has improved since then.

I'm not sure how processwire would interact with http2 though, as most often php doesn't deal with the http layer at all. The webserver in front does pass data onward using fastcgi or whatever mod_php does.

Link to comment
Share on other sites

1 hour ago, LostKobrakai said:

I'm not sure how processwire would interact with http2 though

I was thinking that the PW admin could push its js and css assets, but as I mentioned above, it does seem like there might be some caching issues with "push", so maybe it's not worth worrying about and just stick with swapping to http/2 and making sure that the ALPN extension is enabled?

Link to comment
Share on other sites

This is all dependent on the server, nothing to do with php as far as I know. If the cache headers are there (which they are for PW admin assets) then it should just work out of the box. See below for one of my sites, all assets h2 brotli encoded and server from browser cache:

 

B3C7B2FF-9C33-4461-AFFF-8CC89E9B0455.jpg

Edited by Mikie
Image seemed to have disappeared.
Link to comment
Share on other sites

Above is off topic sorry, I was getting push confused with the http/2 functionality of all resources getting sent async in a single connection (which does happen out the box).

Yes, push is confusing and it seems there are no real standards or guidance on how to use it. I feel it is pretty extreme optimisation since after first load things are cached anyway. What would be a candidate for push in PW Admin, assets from unloaded modules or image previews or something?

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
On 11/17/2019 at 2:34 AM, Mikie said:

Adrian is wondering if pw core should be doing any of this. Any thoughts on what could specifically be optimised in the admin?

I was getting the impression the discussion was more "in general", not PW-admin-specific. (concerning our so-called "frontend" product we ship to clients)

There's always a lot you can optimize one way or another.

With the specific tools / methods I briefly mentioned, you could certainly optimize a few milliseconds per page load in the admin. But the major bottlenecks would still be there. So, in brief - no, not worth to optimize in this regard (imho). Of all CMS backends I have come across, PW is already faster than most.

The crucial thing of any "backend" kind of web-app is: You don't want anything to cache your current view when it shouldn't. If you just edited a page and went back to that same page, you expect to view the latest / current view.

I can imagine that a (drastic, i.e. from-the-ground-up) refactoring of the entire PW admin, with a framework like Angular (Vue, React...) would significantly speed things up. But that's a completely new topic, far from trivial, and would really mean a LOT of refactoring...

As someone once mentioned, PW admin loads all template and field infos, plus role-/access-based stuff on load. And this takes a lot of time. Of course you could cache that in order to save a few milliseconds, but then again - an admin web view needs the latest state, always. Without completely switching to a modern SPA framework and radical code-rewrite, I don't see much (noticeable) benefits from just using resource hints.

The DOM itself is one of the biggest show-stoppers here...

  • Like 1
Link to comment
Share on other sites

13 hours ago, dragan said:

PW admin loads all template and field infos, plus role-/access-based stuff on load

Not only the admin. That's part of processwires bootstraping and applies to any request served by processwire.

13 hours ago, dragan said:

Of course you could cache that in order to save a few milliseconds, but then again - an admin web view needs the latest state, always.

This applies to (user-)data shown, but not to more or less static resources like scripts or static images of the admin / other modules.

Link to comment
Share on other sites

2 hours ago, LostKobrakai said:

This applies to (user-)data shown, but not to more or less static resources like scripts or static images of the admin / other modules.

Sure. For static resources, Cache API + service worker would probably bring speed performance. Ideally (to avoid DOM / GUI re-rendering on each page load) combined with an SPA setup. Or in PWA-speak, using an app shell.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...