Which is the right way to load and cache data for the whole application? Directly in application/config/app.php or in a service provider?
For a single block I would extend the controller with such a function
public function getData()
{
$expensiveCache = $this->app->make('cache/expensive');
$cacheItem = $expensiveCache->getItem('Localize/list');
if ($cacheItem->isMiss()) {
$cacheItem->lock();
@$JSON = file_get_contents("https://raw.githubusercontent.com/benoitvallon/100-best-books/master/books.json");
if($JSON == FALSE) {
echo 'json empty';
return '';
}
$data = json_decode($JSON);
$expensiveCache->save($cacheItem->set($localized)->expiresAfter(300));
else {
$data = $cacheItem->get();
}
return $data;
}