Module | Merb::ConditionalGetMixin |
In: |
lib/merb-core/controller/mixins/conditional_get.rb
|
Provides conditional get support in Merb core. Conditional get support is intentionally simple and does not do fancy stuff like making ETag value from Ruby objects for you.
The most interesting method for end user is +request_fresh?+ that is used after setting of last modification time or ETag:
@example
def show self.etag = Digest::SHA1.hexdigest(calculate_cache_key(params)) if request_fresh? self.status = 304 return '' else @product = Product.get(params[:id]) display @product end end
Value of the ETag header
@return [String] Value of ETag response header if set. @return [nil] If ETag header not set.
@api public
Sets ETag response header by calling to_s on the argument
@param tag [to_s] value of ETag header
@return [String] value of ETag header enclosed in double quotes as required by the RFC
@api public
Test to see if the request‘s Etag matches the one supplied locally
@return [true] if ETag response header equals If-None-Match request header @return [true] if it does not.
@api public
Value of the Last-Modified header
@return [Time] Value of Last-Modified response header if set. @return [nil] If Last-Modified not set.
@api public