Improve block rendering #2447
Replies: 2 comments
-
Hi @amargoCactus, It seems like you're saying that the amount of queries is strictly due to Twill, so I have a couple questions for you.
Regarding caching, I don't think it is Twill's responsibility to handle caching of the data you render on your frontend. Laravel has a lot of caching options though, both internal and external, and they all work very well with Twill, so I would suggest looking into that. We have websites that require large amount of queries for certain things that would result in unacceptable TTFB numbers, but with a CDN or response cache, we can still serve them at sub 50ms TTFB. |
Beta Was this translation helpful? Give feedback.
-
i tried to eager load my //routes/web.php
Route::group([
'prefix' => LaravelLocalization::setLocale(),
'middleware' => ['localize', 'localeSessionRedirect', 'localizationRedirect', 'localeViewPath'],
], function () {
Route::get('{slug?}', [PageController::class, 'index'])->name('pages.index');
}) <?php
namespace App\Http\Controllers\Site;
use App\Models\Page;
use App\Http\Controllers\Controller;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class PageController extends Controller
{
public function defaultPage()
{
$default = Page::first();
return redirect()->route('pages.index', $default->slug);
}
public function index($slug)
{
try {
$data = Page::forSlug($slug)->first();
if (!$data) {
throw new NotFoundHttpException();
}
} catch (\Exception $e) {
throw new NotFoundHttpException();
}
return view('site.pages', ['data' => $data]);
}
}
The homepage for the moment has 6 blocks
Agree, but i think it would be nice if |
Beta Was this translation helpful? Give feedback.
-
Summary
When many blocks that use medias, translations, repeaters and any feature that needs to query a model are render, it strongly affects the server response performance (TTFB) and debugbar indicates a huge number of queries, it affects the performance a lot, in my case the page is taking 13 seconds for TTFB
Describe the solution you'd like
Maybe eager loading or caching?
Additional context
Beta Was this translation helpful? Give feedback.
All reactions