bmizerany (owner)

Revisions

gist: 106718 Download_button fork
public
Public Clone URL: git://gist.github.com/106718.git
Embed All Files: show embed
Text only #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module Sinatra
 
   module CacheControl
 
    ##
    # cache_control :public => true, :max_age => 5
    # Cache-Control=public, max-age=5
    def cache_control(options)
      parts = options.map do |k,v|
        if v == true
          k.to_s
        else
          "#{k.to_s.tr("_", "-")}=#{v}"
        end
      end
      headers["Cache-Control"] = parts.join(",")
    end
 
   end
 
end