Sha256: 5123756ba6ab578a263eee6111aa6f25747eeae5acbb4db02aa4c64515140640

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

# Caching and Performance


## Caching

### Fragment Caching

If you wish to do fragment caching that includes React on Rails rendered components, be sure to
include the bundle name of your server rendering bundle in your cache key. This is analogous to 
how Rails puts an MD5 hash of your views in the cache key so that if the views change, then your 
cache is busted. In the case of React code, if your React code changes, then your bundle name will
change due to the typical inclusion of a hash in the name.

Call this method to get the server bundle file name:

```ruby
# Returns the hashed file name of the server bundle when using webpacker.
# Nececessary fragment-caching keys.
ReactOnRails::Utils.server_bundle_file_name
```

### HTTP Caching

When creating a HTTP cache, you want the cache key to include your client bundle files.

Call this method to get the client bundle file name. Note, you have to pass which bundle name.

```ruby
# Returns the hashed file name when using webpacker. Useful for creating cache keys.
ReactOnRails::Utils..bundle_file_name(bundle_name)
```

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
react_on_rails-10.1.4 docs/additional-reading/caching-and-performance.md
react_on_rails-10.1.3 docs/additional-reading/caching-and-performance.md
react_on_rails-10.1.1 docs/additional-reading/caching-and-performance.md
react_on_rails-10.1.0 docs/additional-reading/caching-and-performance.md