ASP.NET Core response cache

ASP.NET Core comes with built-in support for response caching. Unlike cache-control header that tells client/proxies how long to cache data, the response cache will cache output of an action.

The advantage of caching is that you can decrease the amount of expensive operations on the server by caching the result.

Install

Use

The simplest form of this caching is to decorate an action with the ResponseCache attribute. Duration says how many seconds to cache the output.

Note that the output may vary depending on HTTP headers, query variables, or post data. If this is the case then you need to specify so. For example:

Response caching supports much more complex scenarios.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: