3

I know ResponseCache attribute can caching page in client side by http headers attribute cache-control.

And ResponseCache middleware, it caching page on server (same http headers as ResponseCache attribute).

I compare these, it seems no different, same features, same condition.

Server side caching is no different from ResponseCache attribute, they both don't let the request into controller action, or these have different request pipeline ?

So, What kind of scenarios would choose ResponseCache middleware/ ResponseCache attribute?

Jim G.
  • 15,141
  • 22
  • 103
  • 166
Vic
  • 758
  • 2
  • 15
  • 31

1 Answers1

-1

From documentations and source code, we can find:

Response Caching Middleware

determines when responses are cacheable, stores responses, and serves responses from cache.

ResponseCache Attribute specifies the parameters necessary for setting appropriate headers in response caching.

It is used to configure and create (via IFilterFactory) a ResponseCacheFilter. The ResponseCacheFilter performs the work of updating the appropriate HTTP headers and features of the response. The filter:

  • Removes any existing headers for Vary, Cache-Control, and Pragma.

  • Writes out the appropriate headers based on the properties set in the ResponseCacheAttribute.

  • Updates the response caching HTTP feature if VaryByQueryKeys is set.

For more information, please check:

Fei Han
  • 26,415
  • 1
  • 30
  • 41