Skip to content

Commit 7ee030d

Browse files
committed
✨ Add VaryByQueryKeys usage for ResponseCaching.
1 parent 242ba46 commit 7ee030d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

sample/EasyCaching.Demo.ResponseCaching/Controllers/HomeController.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
namespace EasyCaching.Demo.ResponseCaching.Controllers
22
{
33
using Microsoft.AspNetCore.Mvc;
4-
using System;
5-
4+
using System;
5+
66
public class HomeController : Controller
77
{
88
[ResponseCache(Duration = 20)]
@@ -21,5 +21,13 @@ public IActionResult About()
2121
LastUpdated = DateTimeOffset.UtcNow.ToString()
2222
});
2323
}
24+
25+
//not cached by query
26+
//[ResponseCache(Duration = 20)]
27+
[ResponseCache(Duration = 30, VaryByQueryKeys = new string[] { "page" })]
28+
public IActionResult List(int page = 0)
29+
{
30+
return Content(page.ToString());
31+
}
2432
}
2533
}

0 commit comments

Comments
 (0)