K
K
kupurim2019-03-11 20:23:19
Laravel
kupurim, 2019-03-11 20:23:19

How to cache (cache queries to the database) a site on Laravel?

Hello.
There is a site on Laravel 5.
On the main page, 100-200 records are displayed, in total there are 9 queries to the database on the main page, but they work a little for a long time.
Threw a query to the database in the cache:

Cache::remember('data', 60, function(){
  return DB::table('articles');
});

And now the question is, does it make sense to throw all requests there or only the most difficult ones?
Will it be a load on the server? What is the best way to use this cache?
Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question