Browse files

Merge pull request #29964 from gwincr11/cg-partial-caching

Add documentation about template partial caching
  • Loading branch information...
eileencodes committed Aug 30, 2017
2 parents 87eb1a2 + 49f6c47 commit 86389b41436e7020a403c72669cf7748850fb15e
Showing with 18 additions and 0 deletions.
  1. +18 −0 guides/source/
@@ -179,6 +179,24 @@ With `touch` set to `true`, any action which changes `updated_at` for a game
record will also change it for the associated product, thereby expiring the
### Shared Partial Caching
It is possible to share partials and associated caching between files with different mime types. For example shared partial caching allows template writers to share a partial between HTML and Javascript files. When templates are collected in the template resolver file paths they only include the template language extension and not the mime type. Because of this templates can be used for multiple mime types. Both HTML and JavaScript requests will respond to the following code:
render(partial: 'hotels/hotel', collection: @hotels, cached: true)
Will load a file named `hotels/hotel.erb`.
Another option is to include the full filename of the partial to render.
render(partial: 'hotels/hotel.html.erb', collection: @hotels, cached: true)
Will load a file named `hotels/hotel.html.erb` in any file mime type, for example you could include this partial in a Javascript file.
### Managing dependencies
In order to correctly invalidate the cache, you need to properly define the

0 comments on commit 86389b4

Please sign in to comment.