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

Add early hints feature #1403

Merged
merged 1 commit into from Oct 4, 2017
Merged

Commits on Oct 3, 2017

  1. Add early hints feature

    This commit adds the early hints lambda to the headers hash. Users can
    call it to emit the early hints headers. For example:
    
    ```
    class Server
      def call env
        if env["REQUEST_PATH"] == "/"
          env['rack.early_hints'].call("Link" => "</style.css>; rel=preload; as=style\n</script.js>; rel=preload")
          [200, { "X-Hello" => "World" }, ["Hello world!"]]
        else
          [200, { "X-Hello" => "World" }, ["NEAT!"]]
        end
      end
    end
    
    run Server.new
    ```
    
    In this example, the server sends stylesheet and javascript early hints
    if the proxy supports it, it will send H2 pushes to the client.
    
    Of course not every proxy server supports early hints, so to enable the
    early hints feature with puma you have to pass the configuration variable,
    `--early-hints`.
    
    If `ENV['rack.early_hints']` is not set then early hints is not
    supported by the webserver. Early hints is off by default.
    eileencodes committed Oct 3, 2017
    Copy the full SHA
    ea37ada View commit details
    Browse the repository at this point in the history