Cache Blade Views Into a Single File #41855
Unanswered
EvilLooney
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I have been refactoring some older code and decided to use reusable Blade-X Components as they are much easier to work with and I can save development time for other projects using similar techniques. However, I have hit a wall when dealing with index pages, specifically admin pages displaying lists of models. The time to render the page has jumped significantly (in my case, the response time jumped from less than 200ms to more than 800ms). I have a feeling that I am not the only one who's facing this problem.
Consider this simplified code:
App/Http/Controllers/ProductsController.php
ressources/views/products/index.blade.php
ressources/views/products/index-row.blade.php
ressources/views/components/belongs-to.blade.php
ressources/views/components/model-view.blade.php
ressources/views/components/model-edit.blade.php
ressources/views/components/model-delete.blade.php
Of course, the problem is exasperated when we add more columns, more rows and more components (especially when nested).
Now if we take this code, the render time is significantly reduced:
So my idea is that, instead of caching each individual blade file, wouldn't it make sense to compile the view
products.index
with all of its child views into one file?Notes:
@for ($i = 0; $i < 10000; $i++) <div></div> @endfor
vs.@for ($i = 0; $i < 10000; $i++) @include('div') @endfor
shows how much faster the former is. Plus writing the component syntax simplifies everything.Sorry for the long post but I tried the best I can to convey my point. I know there is a tradeoff splitting views into separate files vs rendering time but maybe this could make it more bearable.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions