As I understand HTTP/2 can send the website assets (images, scripts, css files, etc) over a single connection, as well as push them. I am interested in how this actually happens in practice.
How does a general-purpose server (such as Apache or nginx) decide what to send and what? In particular, I understand that in theory the server can push data that it knows will be requested, but how does it know what to send?
For example, let's say you have a webserver (Apache or nginx) configured with an index.php script which generates a page and a number of assets. Does the webserver automatically parse the output of index.php and send all the requisite files along with the response? Or does the index.php file need to specify this somehow?
Or is it the case that while possible in theory, this doesn't happen in practice, and the browser just makes a request for the assets later?