Replies: 2 comments 1 reply
-
In Rails to use fragment caching effectively with Phlex you should return the content as a string. So you need to capture the output of the Phlex component rendering and then cache it. You can try to use a buffer:
|
Beta Was this translation helpful? Give feedback.
-
It’s not possible to use fragment caching with Phlex, because you would need to track all the dependencies. Even ActionView doesn’t do this very well. However, Phlex is so fast, it’s not necessary to use fragment caching. You can use caching to speed up database queries or API requests, while continuing to render views on the fly. The views won't be the bottleneck. |
Beta Was this translation helpful? Give feedback.
-
I'm wondering if there's any way to use Rails fragment caching with Phlex?
I've got this basic view which tries to write to the cache but since the rendering happens later instead of being returned, it's caching
nil
I had a brief look at the code for Phlex and didn't see anything obvious that matches what I'm trying to do. Have I missed something? Is there a different way to do fragment caching I'm not aware of?
Beta Was this translation helpful? Give feedback.
All reactions