mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
changes caching guide to add note on weak etags
This commit is contained in:
parent
2c02bc0a47
commit
a6f8526ee6
1 changed files with 8 additions and 0 deletions
|
@ -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
|
||||
----------
|
||||
|
||||
|
|
Loading…
Reference in a new issue