#cached_svelte_component
<%= cached_svelte_component 'HelloWorld', options: { cache_key: @user } %>
Caches the rendered Svelte component. Requires the redis gem.
This requires ruby 3+! For older rubies see cached_svelte_component_ruby2
Additional Options
cache_key(String, Array or ActiveRecord-object): Custom cache key (optional).expires_in(Time): Cache duration (e.g.,8.hours).
Cache Key Format
Example: svelte-on-rails:development:HelloWorld.svelte-1xq5tnu-User1:fscyhz-18bm76a-j4k6FGH
Composed of:
- Namespace (
svelte-on-rails, configurable) - Environment (e.g.,
development) - Component filename
- Checksum of component file path
- Custom
cache_key(if provided) - Checksum of file modification timestamp
- Checksum of props
- Checksum of arguments