Jump to content
adrian

HTTP/2 Push

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

Share this post


Link to post
Share on other sites

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. 😉 

Share this post


Link to post
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 😞 ).

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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?

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...