nbibler (owner)

Revisions

gist: 219944 Download_button fork
public
Public Clone URL: git://gist.github.com/219944.git
Embed All Files: show embed
prefetch_killer.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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