elabx Posted May 23 Share Posted May 23 Example: foreach($list_of_cards as $card){ // cache cleared then selector matches $files->render("inc/some-include", $vars , ["cache" => "template=some_template", "name" => "template_cache_{$card->id}"]) } Available since version 3.0.130 7 Link to comment Share on other sites More sharing options...
monollonom Posted May 24 Share Posted May 24 Thanks for sharing, I should look into this as I also use this a lot. Does it cache per file or per render call? Or maybe you have a unique name in your $vars? 1 Link to comment Share on other sites More sharing options...
elabx Posted May 24 Author Share Posted May 24 You're right @monollonom, it doesn't seem to cache per render per call which would be the most useful case! Looking at the usage in TemplateFile class, it seems the options passed to render() get passed on to $cache->renderFile(), where we can pass on the name paremeter to specify a unique cache name. Updated the example! 5 hours ago, monollonom said: Thanks for sharing, I should look into this as I also use this a lot. I had a very simple case where I was delegating the rendering of list items to another file and I was very surprised how slow everything turned, ProfilerPro was very usefull figuring this out. It wasn't even a big list, just like 40-50 items. I kept debugging what was inside the include file until finally figuring out it was the render() call that killed performance. 2 Link to comment Share on other sites More sharing options...
Jan Romero Posted May 25 Share Posted May 25 Interesting! Unfortunately it doesn’t seem like this can be used with $page->render(), because it’s built outside of TemplateFile::render(), but I’ve only taken a quick look at the code on my phone, so I may be wrong… I have a lot of places where I wrap stuff like this in cache()->get(). Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now