Is it possible to push files using http2 using wildcards, something like:
header("Link: </wp-content/java-*.js>; rel=preload; as=script", false);
Where java-1.js. java-2.js etc will be preloaded using the http2 protocol? Or maybe all .js in one folder, such as:
header("Link: </wp-content/cache/wpo-minify/*.js>; as=script; rel=preload", false); //3k
Obviously, the above won't work.
The link header method of pushing assets is not part of the HTTP/2 standard and is just a common method used to indicate pushes. You haven’t said which web server you’re using but I’m not aware of any web server that allow wildcards.
So you will need to do this yourself, look up the files in your PHP files, and then add a link header for each file.
However if really advise you think heavily before doing this. HTTP/2 Push has been a bit of a disappointment, rarely has been shown to cause improvements, and is easily overused. You really should only push the bare minimum as push is not free and by using that, you are filling up the network with resources that maybe aren’t the most important. Browsers are very clever about requesting resources in the tight order and push just pushes all over that. Using wildcards seems like the opposite to that.
Push also ignores if the browser already has the file in its cache and just sends it again. There are ways of working around this (e.g. using cookies) but they require some thought and set up, at which point you’re dynamically setting the headers and so can implement the wildcards logic yourself as described above.
Chrome have indicated their intention to remove HTTP/2 push support and never implemented it for HTTP/3.
So it’s difficult to recommend HTTP/2 Push, and especially in pushing multiple resources with a wildcard, such as you are asking to do.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments