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

Use environment variable as parameter to directive 'H2PushResource' #248

Open
maborec opened this issue Apr 12, 2023 · 2 comments
Open

Use environment variable as parameter to directive 'H2PushResource' #248

maborec opened this issue Apr 12, 2023 · 2 comments

Comments

@maborec
Copy link

maborec commented Apr 12, 2023

This is a feature request I think can be very useful.
It seems "early hints" are gaining relevance lately to speed up page loads.
If I'm not wrong, currently, mod_http2 allows to set early hints only using static URLs, eg.:
H2EarlyHints on
H2PushResource /xxx.css

It would be great if we could set the parameter to the directive using a calculated environment variable, for example:

  1. Calculate the env variable:
    SetEnvIf REQUEST_URI "^pagel\/(.*)$" EARLY_HINT_URL=/image/$1.jpg

  2. Pass the env variable to H2PushResource:
    H2PushResource %{EARLY_HINT_URL}e

As far as I have seen, this is not currently possible.
Taking a quick look at mod_include, I guess it could be done with something similar to include_expr_lookup in
https://github.com/omnigroup/Apache/blob/master/httpd/modules/filters/mod_include.c

...or maybe using the Apache expression parser, ap_expr.h.

@maborec maborec changed the title Use environment variables as paraters to directive 'H2PushResource' Use environment variable as parameter to directive 'H2PushResource' Apr 12, 2023
@icing
Copy link
Owner

icing commented May 10, 2023

I like the idea. I am currently adding a H2EarlyHintLink directive that gets the complete content of a Link: header configured. Reason being that browser keep tweaking this header and I am not eager to follow any attribute change. So one can do

H2EarlyHintLink "</path/image.jpg>; rel=preload; as=image"

Now, mod_http2 could also auto-pick up such links from the environment. Let's say EARLY_HINT_LINK. But since there can be more than one, maybe all env vars matching EARLY_HINT_LINK* should be used?

WDYT?

@dimasites
Copy link

dimasites commented Aug 10, 2023

hi @icing and thanks for awesome mod_http2!

By issue: as said rfc8288 :

this header field:

Link: <https://example.org/>; rel="start",
      <https://example.org/index>; rel="index"
is equivalent to these:

Link: <https://example.org/>; rel="start"
Link: <https://example.org/index>; rel="index"

That means we (you :) ) can support one variable for full-featured implementation!

P.S. Please suggest, when H2EarlyHintLink will be released? Or may be i missed and this alredy done? Cant find reference in changelog... it wiil be cool to have full control this heading!

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

No branches or pull requests

3 participants