From a6f8526ee68d1b8a33b5e112dd8ff3d2ace4ad69 Mon Sep 17 00:00:00 2001 From: Abhishek Yadav Date: Wed, 24 Feb 2016 22:48:28 +0530 Subject: changes caching guide to add note on weak etags --- guides/source/caching_with_rails.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/guides/source/caching_with_rails.md b/guides/source/caching_with_rails.md index 3a1a1ccfe6..2df478b5aa 100644 --- a/guides/source/caching_with_rails.md +++ b/guides/source/caching_with_rails.md @@ -521,6 +521,14 @@ class ProductsController < ApplicationController end ``` +### A note on weak ETags + +Etags generated by Rails are weak by default. Weak etags allow symantically equivalent responses to have the same etags, even if their bodies do not match exactly. This is useful when we don't want the page regenerated for minor changes in response body. If you absolutely need to generate a strong etag, it can be assigned to the header directly. + +```ruby + response.add_header "ETag", Digest::MD5.hexdigest(response.body) +``` + References ---------- -- cgit v1.2.3