Skip to content
Browse files

this is getting a little annoying. i've been too clever for my own good.

  • Loading branch information...
1 parent e6d05bd commit 255974ef814ea88cd449417a8ee7c5610a1b1d94 @peburrows committed Feb 8, 2008
Showing with 19 additions and 0 deletions.
  1. +19 −0 app/models/translate_response_cache.rb
View
19 app/models/translate_response_cache.rb
@@ -75,5 +75,24 @@ def page_cache_path(path)
cache_path
end
end
+
+ # Reads a cached response from disk and updates a response object.
+ def read_response(path, response, request)
+ file_path = page_cache_path(path)
+ if metadata = read_metadata(path)
+ response.headers.merge!(metadata['headers'] || {})
+ if client_has_cache?(metadata, request)
+ # we need to see if this is really what we want to do. it causes issues with localization
+ # since I'm being "smart" and sending the same url. ugh. I might be too "smart" for my
+ # own good on this one
+ # response.headers.merge!('Status' => '304 Not Modified')
+ elsif use_x_sendfile
+ response.headers.merge!('X-Sendfile' => "#{file_path}.data")
+ else
+ response.body = File.open("#{file_path}.data", "rb") {|f| f.read}
+ end
+ end
+ response
+ end
}
end

0 comments on commit 255974e

Please sign in to comment.
Something went wrong with that request. Please try again.