komposable / komponent

An opinionated way of organizing front-end code in Ruby on Rails, based on components
http://komponent.io
MIT License
427 stars 31 forks source link

Caching implementation #77

Closed Spone closed 6 years ago

Spone commented 6 years ago

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 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?)

Feel free to comment with your ideas below!