File: conditional_get.rb

# conditional_get.rb

Path: | lib/merb-core/controller/mixins/conditional_get.rb
Last Update: | Tue Mar 03 13:34:13 -0700 2009

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

[Validate]