hypernova icon indicating copy to clipboard operation
hypernova copied to clipboard

Rails Action Cache with Hypernova

Open gbateman opened this issue 6 years ago • 3 comments

I was trying to implement action caching using actionpack-action_caching but because of how hypernova works with render tokens, the cached result is just the render token. Furthermore, it is clearly useless to call the after action after returning such a result, because there were no calls to render_react_component if the result was cached. It would be nice if there was a supported way to enable caching on hypernova rendered components.

Currently I am storing the results of @hypernova_batch.submit! in the rails cache and then manually replacing the batch tokens from the cached results in an after action, but this method is not easy to abstract, and feels unclean.

gbateman avatar May 22 '18 20:05 gbateman

I'm not familiar with how action caching works, but I'd assume it would need to run after all filters - and hypernova runs in an around_filter. If it's not doing that, then it's probably caching the wrong thing in a number of cases.

ljharb avatar May 23 '18 00:05 ljharb

Yeah, it seems like action caching takes the result from before after_filters though - not what hypernova could do to get around that if anything

gbateman avatar May 23 '18 03:05 gbateman

I don't think there's anything; it seems like a flaw/bug in action cache, tbh.

ljharb avatar May 23 '18 03:05 ljharb