Skip to content

Instantly share code, notes, and snippets.

@nbibler
Created October 27, 2009 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nbibler/219944 to your computer and use it in GitHub Desktop.
Save nbibler/219944 to your computer and use it in GitHub Desktop.
module Rack
class PrefetchKiller
def initialize(app, options = {})
@app = app
end
def call(env)
google_prefetch?(env) ? head_forbidden : @app.call(env)
end
private
def google_prefetch?(environment)
environment["HTTP_X_MOZ"] == "prefetch"
end
def head_forbidden
[403, {'Content-Type' => 'text/html; charset=utf-8'}, [' ']]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment