-
-
Notifications
You must be signed in to change notification settings - Fork 630
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added 2 helpers to get hashed file names
Added 2 cache helpers: ReactOnRails::Utils.bundle_file_name(bundle_name) ReactOnRails::Utils.server_bundle_file_name for easy access to the hashed filenames for use in cache keys
- Loading branch information
Showing
6 changed files
with
116 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# 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) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
PENDING: | ||
# View Helpers | ||
See the [app/helpers/react_on_rails_helper.rb](../../app/helpers/react_on_rails_helper.rb) source. | ||
|
||
Should we document the view helpers here concisely? | ||
# Controller Helpers | ||
See the [lib/react_on_rails/controller.rb](../../lib/react_on_rails/controller.rb) source. | ||
|
||
# Utility Methods | ||
See the [lib/react_on_rails/utils.rb](../../lib/react_on_rails/utils.rb) source. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters