-
-
Save yigitbacakoglu/8b4bb770cc3251e79b52922a3b5bddb9 to your computer and use it in GitHub Desktop.
Revisions
-
yigitbacakoglu created this gist
Jun 7, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ 3- Explain how you would implement a caching strategy for a page that shows the most recent posts to reduce database load. - 3.1- Explain fragment Caching ``` <table> <thead> <tr> <th>Title</th> <th>Description</th> <th>Image url</th> <th>Price</th> <th colspan="3"></th> </tr> </thead> <tbody> <% @products.each do |product| %> <%= render product %> <% end %> </tbody> </table> - 3.2- Explain Low-Level Caching ``` recent_posts = Rails.cache.fetch('recent_posts', expires_in: 10.minutes) do Post.order(created_at: :desc).limit(10).to_a end ``` ---