Permalink
Browse files

To fix issue on padrino 0.10.5: "Padrino::Cache::Helpers::Page return…

…s Content-Type: text/html on all cached pages."

Store both response_buffer and content_type in cache. Same as padrino@8f746e0
  • Loading branch information...
pqnga committed Jun 8, 2012
1 parent d65e4a0 commit f545d4c040cf4820729c78fb0b58ecb359a1e309
Showing with 12 additions and 3 deletions.
  1. +12 −3 padrino-cache/lib/padrino-cache/helpers/page.rb
@@ -93,18 +93,27 @@ def self.padrino_route_added(route, verb, path, args, options, block) # @private
began_at = Time.now
value = settings.cache.get(@route.cache_key || env['PATH_INFO'])
logger.debug "GET Cache", began_at, @route.cache_key || env['PATH_INFO'] if defined?(logger) && value
- halt 200, value if value
+
+ if value
+ content_type(value[:content_type]) if value[:content_type]
+ halt 200, value[:response_buffer] if value[:response_buffer]
+ end
end
end
route.after_filters do
if settings.caching?
began_at = Time.now
+
+ content = {
+ :response_buffer => @_response_buffer,
+ :content_type => @_content_type
+ }
if @_last_expires_in
- settings.cache.set(@route.cache_key || env['PATH_INFO'], @_response_buffer, :expires_in => @_last_expires_in)
+ settings.cache.set(@route.cache_key || env['PATH_INFO'], content, :expires_in => @_last_expires_in)
@_last_expires_in = nil
else
- settings.cache.set(@route.cache_key || env['PATH_INFO'], @_response_buffer)
+ settings.cache.set(@route.cache_key || env['PATH_INFO'], content)
end
logger.debug "SET Cache", began_at, @route.cache_key || env['PATH_INFO'] if defined?(logger)
end

0 comments on commit f545d4c

Please sign in to comment.