Skip to content

nateberkopec/rack_http_preload

Repository files navigation

RackHttpPreload

Requires Ruby 2.0+.

rack_http_preload is only compatible with Rack apps that provide a response object. This response object should be compatible with Rack::Response, namely it should provide response.headers=.

require "rack"

class MyTestRackApp
  include RackHttpPreload
  attr_accessor :response

  def call(env)
    self.response = Rack::Response.new("Hello World!", 200, {})
    # If MIME::Types is available, this gem guesses the appropriate `as` and `type`
    http_preload "application.js"
    response.finish
  end

  # "Link"=>"<application.js>; rel=preload; as=script"
end

About

Add rel=preload Link headers to Rack responses, for fast client loading or HTTP/2 Server Push.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published