Index: lib/http/conditions.rb =================================================================== --- lib/http/conditions.rb (revisione 28) +++ lib/http/conditions.rb (copia locale) @@ -15,6 +15,17 @@ end alias_method '<<', :push + +=begin rdoc +Accessor to an array of additional elements to consider for Etag header's creation. +For example, using ActionController::MimeResponds::InstanceMethods#respond_to for serving different +content depending on request 'Accept' header, it's a good idea to include the used template +in Etag value: +conditions.consider_for_etag << template +=end + def consider_for_etag + @consider_for_etag ||= [] + end def test! return unless @models.size > 0 @@ -31,7 +42,9 @@ end end - response.etag = Digest::MD5.hexdigest(lock_versions.join('|')) + #response.etag = Digest::MD5.hexdigest(lock_versions.join('|')) + etag_values = [].concat(consider_for_etag).concat(lock_versions) + response.etag = Digest::MD5.hexdigest(etag_values.join('|')) response.last_modified = updated_at_dates.compact.sort.last || Time.now raise HTTP::PreconditionFailedError unless match? || unmodified_since?