[PATCH] HTTP/2: expose function to push single resource to modules
mdounin at mdounin.ru
Tue Feb 13 13:31:17 UTC 2018
On Tue, Feb 13, 2018 at 12:21:36PM +0000, Alessandro Ghedini wrote:
> On Fri, Feb 09, 2018 at 10:35:59AM +0300, Ruslan Ermilov wrote:
> > On Thu, Feb 08, 2018 at 07:48:25PM +0000, Alessandro Ghedini wrote:
> > > On Thu, Feb 08, 2018 at 10:00:27PM +0300, Maxim Dounin wrote:
> > > > On Thu, Feb 08, 2018 at 04:52:59PM +0000, Alessandro Ghedini wrote:
> > > >
> > > > > # HG changeset patch
> > > > > # User Alessandro Ghedini <alessandro at ghedini.me>
> > > > > # Date 1518108716 0
> > > > > # Thu Feb 08 16:51:56 2018 +0000
> > > > > # Branch expose-push
> > > > > # Node ID 1bb98b06d5536dfc80a407aabd8d06f9309f8df6
> > > > > # Parent a49af443656f2b65ca5de9d8cad5594f44e18ff7
> > > > > HTTP/2: expose function to push single resource to modules.
> > > > >
> > > > > This makes it possible for 3rd party modules to implement alternative
> > > > > methods for deciding which resources to push to clients on a per-request
> > > > > basis (e.g. by parsing HTML from the response body, by using a custom
> > > > > Link header parser, ...).
> > > > >
> > > > > No functional changes.
> > > >
> > > > Not sure this is a good idea.
> > > >
> > > > You may consider exposing a variable to be used in http2_push
> > > > instead.
> > >
> > > Right, the problem is that as far as I can tell http2_push only supports a
> > > single resource, even when a variable is used, so it wouldn't be possible to
> > > push multiple resources without specifying multiple http2_push directives,
> > > each with its own variable, and even then you'd only have a fixed number of
> > > resources that can be pushed, which wouldn't work well when the number of
> > > resources changes depending on each request/response.
> > >
> > > So in the end exposing the internal functions to modules seemed better than
> > > just trying to make http2_push support multiple resources per directive,
> > > which would add complexity to NGINX itself rather than the external modules
> > > (though I can do that if you think it would be a better solution).
> > We've also considered adding support for the X-Accel-Push header, but
> > decided not to implement it at this time. If implemented, there could
> > be multiple X-Accel-Push headers in the proxied response.
> That might work for us, but it's a somewhat awkward interface to use from
> inside a module, so I'd still prefer something more direct, and as I said,
> exposing the function to modules seemed the least invasive change to NGINX.
> Could you please expand a bit on why you think this might be a bad idea?
> In any case I can look into implementing X-Accel-Push support if you don't
> plan on doing it yourself.
I presonally think that X-Accel-Push is not needed and should not
be added given we already have http2_push. Also, HTTP/2 push as a
technology has enough design problems to introduce additional
If you want to use HTTP2 pushes from a module, consider either
using http2_push with variables as previously suggested (right now
you can use multiple http2_push directives if you want to push
multiple resources), or adding "Link: rel=preload" headers and
More information about the nginx-devel