Sunday, October 18, 2020

Laravel Dynamic caching for website speed!

 Route::get('/{slug}','SiteController@postDetails');

//Example URL: example.com/awesome-post-title public function postDetails($slug){ $post = Cache::remember('posts.'.$slug, function($slug) use($slug) { return Post::where('slug',$slug)->first(); }); return view('frontend.posts.post-details',['post'=>$post]); } To read more: https://bit.ly/speed-up-laravel-website

No comments:

Post a Comment