Closed tubbo closed 4 years ago
Let's do this in base, there are jbuilder templates there too, and that's where the cache varies functionality is. It should look something like this: https://github.com/workarea-commerce/workarea/blob/master/core/lib/workarea/ext/freedom_patches/action_view_cache_helper.rb
To resolve an issue where cached data would still appear in Jbuilder templates even when requesting as a logged-in admin, override the
JbuilderTemplate#cache!
method to perform the same checks as theActionView::Helpers::WorkareaCache
helper when rendering pages as HTML. This ensures that data between API requests and regular HTML requests on the storefront are consistent. The patch is only active for Storefront API controllers, as Jbuilder is used extensively elsewhere and this kind of cache lookup wouldn't work in those contexts.