Of course shouldn't expect caching in post API
But look at this sample code on special controller not in middleware and it is not "build in"
May be useful
public class XController : Controller
{
private readonly IMemoryCache _cache;
public XController(IMemoryCache cache)
{
_cache = cache;
}
[HttpPost]
public async Task<IEnumerable<YourCustomModel>> Post([FromBody] ParamtersModel value)
{
string cacheKey = value.Id.ToString();
IEnumerable<YourCustomModel> cacheEntry = await _cache.GetOrCreate(cacheKey, async entry =>
{
entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(60);
IEnumerable<YourCustomModel> result = await ... your method calling for first time to getting in cache
return result;
});
return cacheEntry;
}
}