1

Does it make sense (performancewise) to store view->execute() as a static variable in order to avoid running same view multiple times?

And then call view->render() wherewer I want to print the view? Does it make any sense? Or are there better options? Thank you

0

It heavily depends on what you're trying to achieve with caching.

If you're trying to avoid additional DB queries, you won't be adding much here. The view::execute() & view::render() are already making use of its own caching system (if it's enabled on the view in question).

If you're trying to avoid all the theme/module hook execution overhead, yeah that will avoid it. Of course, the trade-off is modules/themes won't be able to modify a view (if that's needed) and you'll have to handle other cache invalidation scenarios as a result of your custom caching.

You'll have to make the call depending on how/what you're trying to optimize it that's worth the trade-off (generally, I would say no but that's opinion).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.