Reputation: 2720
I am workinog on Asp.net core 2.1
project. In my project, there is a menu that bind from 2 tables Group
and subGroup
.
Group
Table contains Id
and GroupName
and subGroup
table contains Id
,groupId
and subGroupName
.
Now to improve the speed of loading the site i want use caching.
1 - What is the best way to cache
data from database.
2 - What is the diffrence between <cache></cache>
(Which is used in the view
) and IMemoryCache
(Which is used in the controller
or class
) in asp.net core?
Upvotes: 0
Views: 141
Reputation: 1973
You can use IMemoryCache
if you want to cache just the query results server side or you can use Cache TagHelper
to cache a specific part of the view which may or may not contain the results of that said query.
Also with IMemoryCache
you can have global settings where with Cache TagHelper
you'll have to do it manually for each tag use.
Fun fact: at its core Cache TagHelper
implementation uses an instance of an IMemoryCache
.
Upvotes: 1