Answer the question
In order to leave comments, you need to log in
How to cache paginated output in Laravel 5?
Hello!
Maybe someone came across Laravel 5 with pagination caching.
There were no problems in version 4, I used:
->remember(60)
->paginate(10);
$value = Cache::remember('users', $minutes, function()
{
return DB::table('users')->paginate(15);
});
Answer the question
In order to leave comments, you need to log in
Of course, it will not work, your cache key does not take into account the page number. You need something like (I did not work with the fifth version and there is no way to check the code at hand)
$value = Cache::remember('users-' . \Request::input('page'), $minutes, function()
{
return DB::table('users')->paginate(15);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question