// In this action we'll cache a DateTime three different ways. public async Task <ActionResult> Index() { // This one will be cached using the built-in ASP.NET Core IMemoryCache. var memoryCachedDateTime = await _dateTimeCachingService.GetMemoryCachedDateTimeAsync(); // This one will be using the DynamicCache provided by Orchard Core. It will have a 30 second expiration. var dynamicCachedDateTimeWith30SecondsExpiry = await _dateTimeCachingService.GetDynamicCachedDateTimeWith30SecondsExpiryAsync(); // Finally this date will be cached only for this route. var dynamicCachedDateTimeVariedByRoutes = await _dateTimeCachingService.GetDynamicCachedDateTimeVariedByRoutesAsync(); // NEXT STATION: Services/DateTimeCachingService.cs return(View("Index", new CacheViewModel { MemoryCachedDateTime = memoryCachedDateTime, DynamicCachedDateTimeWith30SecondsExpiry = dynamicCachedDateTimeWith30SecondsExpiry, DynamicCachedDateTimeVariedByRoutes = dynamicCachedDateTimeVariedByRoutes })); }