Actually, we can currently wrap manually the whole component partial in a cache helper, in order to cache it. But maybe Komponent should have a built-in way to do that.
I think we could have an API similar to the render partial one, where you can pass cached: true. Something like: = component "button", cached: true
It would then rely on Rails to do the work.
The main question is: how can we define the key for the cache entry? It could be a method within the Ruby module of the component (cache_key?)
I'm wondering how we could implement fragment caching for the components.
(First, if you're not familiar with the topic, I suggest you read the Rails guide about caching)
Actually, we can currently wrap manually the whole component partial in a
cache
helper, in order to cache it. But maybe Komponent should have a built-in way to do that.I think we could have an API similar to the
render partial
one, where you can passcached: true
. Something like:= component "button", cached: true
It would then rely on Rails to do the work.The main question is: how can we define the key for the cache entry? It could be a method within the Ruby module of the component (
cache_key
?)Feel free to comment with your ideas below!