Skip to content

Commit

Permalink
Explain how to configure collection cache key
Browse files Browse the repository at this point in the history
  • Loading branch information
sedubois committed Oct 11, 2023
1 parent 8776e95 commit 6eeb128
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions guides/source/caching_with_rails.md
Expand Up @@ -122,6 +122,16 @@ All cached templates from previous renders will be fetched at once with much
greater speed. Additionally, the templates that haven't yet been cached will be
written to cache and multi fetched on the next render.

The cache key can be configured. In the example below, it is prefixed with the
current locale to ensure that different localizations of the product page
do not overwrite each other:

```html+erb
<%= render partial: 'products/product',
collection: @products,
cached: ->(product) { [I18n.locale, product] } %>
```

### Russian Doll Caching

You may want to nest cached fragments inside other cached fragments. This is
Expand Down

0 comments on commit 6eeb128

Please sign in to comment.