Sha256: 525cbdef229e0fd15c91d51a1582297a06bef94e74ead8769f4ae4d7cc085102
Contents?: true
Size: 958 Bytes
Versions: 3
Compression:
Stored size: 958 Bytes
Contents
require 'rack/request' module Rack class PageCaching class Response def initialize(response, env) @response, @env = response, env end def cacheable? perform_caching? && caching_allowed? end def path @path ||= request.path end def body @response[2] end def content_type @response[1]['Content-Type'].split(';').first end def gzip_level @env['rack.page_caching.compression'].to_i if @env['rack.page_caching.compression'] end def host request.host end private def request @request ||= Rack::Request.new(@env) end def caching_allowed? method = @env['REQUEST_METHOD'] (method == 'GET' || method == 'HEAD') && @response[0] == 200 end def perform_caching? @env['rack.page_caching.perform_caching'].to_s == 'true' end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rack-page_caching-0.0.3 | lib/rack/page_caching/response.rb |
rack-page_caching-0.0.2 | lib/rack/page_caching/response.rb |
rack-page_caching-0.0.1 | lib/rack/page_caching/response.rb |