adrian Posted November 4, 2019 Share Posted November 4, 2019 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-pushhttps://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. 4 Link to comment Share on other sites More sharing options...
wbmnfktr Posted November 5, 2019 Share Posted November 5, 2019 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. ? Link to comment Share on other sites More sharing options...
horst Posted November 5, 2019 Share Posted November 5, 2019 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 More sharing options...
Mikie Posted November 6, 2019 Share Posted November 6, 2019 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 More sharing options...
LostKobrakai Posted November 6, 2019 Share Posted November 6, 2019 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 More sharing options...
adrian Posted November 6, 2019 Author Share Posted November 6, 2019 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 More sharing options...
Mikie Posted November 6, 2019 Share Posted November 6, 2019 (edited) 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: Edited November 7, 2019 by Mikie Image seemed to have disappeared. Link to comment Share on other sites More sharing options...
Mikie Posted November 6, 2019 Share Posted November 6, 2019 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? 1 Link to comment Share on other sites More sharing options...
Mikie Posted November 15, 2019 Share Posted November 15, 2019 Hi @adrian. Been looking into this more. Is it as simple as just adding the preload directive, then browsers fall back or ignore if unsupported? I have have read the articles posted, but am still not clear on that. Link to comment Share on other sites More sharing options...
Mikie Posted November 15, 2019 Share Posted November 15, 2019 There is also: https://www.tunetheweb.com/performance/http2/http2-push/https://icing.github.io/mod_h2/push.htmlhttps://www.manning.com/books/http2-in-action Link to comment Share on other sites More sharing options...
dragan Posted November 16, 2019 Share Posted November 16, 2019 If you're serious about performance and don't have http2 available, you can optimize a lot with resource hints and service workers + cache API. 1 Link to comment Share on other sites More sharing options...
Mikie Posted November 17, 2019 Share Posted November 17, 2019 @dragan cool thanks. Adrian is wondering if pw core should be doing any of this. Any thoughts on what could specifically be optimised in the admin? Link to comment Share on other sites More sharing options...
dragan Posted November 18, 2019 Share Posted November 18, 2019 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... 1 Link to comment Share on other sites More sharing options...
LostKobrakai Posted November 19, 2019 Share Posted November 19, 2019 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 More sharing options...
dragan Posted November 19, 2019 Share Posted November 19, 2019 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 More sharing options...
Recommended Posts