• What Is Server Push, Exactly?
  • #">What Problems Does Server Push Solve? #
  • #">How To Use Server Push #
    • #">SETTING THE Link HEADER IN YOUR SERVER CONFIGURATION #
    • #">SETTING THE Link HEADER IN BACK-END CODE #
    • #">PUSHING MULTIPLE ASSETS #
  • #">How To Tell Whether Server Push Is Working #
  • #">Measuring Server Push Performance #
    • #">TESTING METHODOLOGY #
    • #">TEST OUTCOMES #
  • #">Caveats On Using Server Push #
    • #">YOU CAN PUSH TOO MUCH STUFF #
    • #">YOU CAN PUSH SOMETHING THAT’S NOT ON THE PAGE #
    • #">CONFIGURE YOUR HTTP/2 SERVER PROPERLY #
    • #">PUSHES MAY NOT BE CACHED #
  • #">Final Thoughts #

    Ref:

    QUICK SUMMARY ↬ The landscape for the performance-minded developer has changed significantly in the last year or so, with the emergence of HTTP/2 being perhaps the most significant of all. No longer is HTTP/2 a feature we pine for. It has arrived, and with it comes server push!
    Aside from solving common HTTP/1 performance problems (e.g., head of line blocking and uncompressed headers), HTTP/2 also gives us server push! Server push allows you to send site assets to the user before they’ve even asked for them. It’s an elegant way to achieve the performance benefits of HTTP/1 optimization practices such as inlining, but without the drawbacks that come with that practice.
    In this article, you’ll learn all about server push, from how it works to the problems it solves. You’ll also learn how to use it, how to tell if it’s working, and its impact on performance. Let’s begin!

    What Is Server Push, Exactly?

    Accessing websites has always followed a request and response pattern. The user sends a request to a remote server, and with some delay, the server responds with the requested content.
    The initial request to a web server is commonly for an HTML document. In this scenario, the server replies with the requested HTML resource. The HTML is then parsed by the browser, where references to other assets are discovered, such as style sheets, scripts and images. Upon their discovery, the browser makes separate requests for those assets, which are then responded to in kind.
    image.png
    Typical web server communication (Large preview)
    The problem with this mechanism is that it forces the user to wait for the browser to discover and retrieve critical assets until after an HTML document has been downloaded. This delays rendering and increases load times.
    With server push, we have a solution to this problem. Server push lets the server preemptively “push” website assets to the client without the user having explicitly asked for them. When used with care, we can send what we know the user is going to need for the page they’re requesting.
    Let’s say you have a website where all pages rely on styles defined in an external style sheet named styles.css. When the user requests index.html from the server, we can push styles.css to the user just after we begin sending the response for index.html.
    image.png
    Web server communication with HTTP/2 server push. (Large preview)
    Rather than waiting for the server to send index.html and then waiting for the browser to request and receive styles.css, the user only has to wait for the server to respond with both index.html and styles.css on the initial request. This means that the browser can begin rendering the page faster than if it had to wait.
    As you can imagine, this can decrease the rendering time of a page. It also solves some other problems, particularly in front-end development workflows.

    What Problems Does Server Push Solve? #

    While reducing round trips to the server for critical content is one of the problems that server push solves, it’s not the only one. Server push acts as a suitable alternative for a number of HTTP/1-specific optimization anti-patterns, such as inlining CSS and JavaScript directly into HTML, as well as using the data URI scheme to embed binary data into CSS and HTML.
    These techniques found purchase in HTTP/1 optimization workflows because they decrease what we call the “perceived rendering time” of a page, meaning that while the overall loading time of a page might not be reduced, the page will appear to load faster for the user. It makes sense, after all. If you inline CSS into an HTML document within