liveBook · Manning

Cacheability

As explained in Building Web APIs with ASP.NET Core

Cacheability is the REST constraint that specifies whether and for how long a response may be reused from a cache.

Cacheability is a REST constraint: a response must indicate whether its data may be reused for a later, equivalent request. HTTP response headers carry that decision. Clear caching rules can reduce client work and improve API performance without accidentally serving stale data. section 8.2 section 1.1.4

For a board-game API built with ASP.NET Core, the [ResponseCache] attribute sets Cache-Control directives on controller responses:

  • Mark a GET response cacheable with [ResponseCache(Location = ResponseCacheLocation.Any, Duration = 60)]. section 8.2
  • Prevent storage of a response with [ResponseCache(NoStore = true)]. section 8.2

Apply the appropriate setting to each response, then check its Cache-Control header. Clients and intermediate proxies use these directives to decide whether they may reuse the response. The practical choice is not simply whether caching is faster, but whether reuse is safe for that response. section 8.2 section 1.1.4

How Building Web APIs with ASP.NET Core covers it

How deep it goes
Defines response reuse and demonstrates attribute settings, stopping at HTTP headers rather than detailing cache internals.
Examples
Shows [ResponseCache] configured with a 60-second duration for cacheable responses and NoStore for noncacheable responses.
What it assumes
Assumes familiarity with HTTP requests and controller methods while defining the REST cacheability constraint.
What you can do after
Apply it via ASP.NET Core [ResponseCache] to label controller responses cacheable or noncacheable.
How it connects
Links REST constraints, HTTP response headers, client caches, intermediate proxies, and API scalability.

Also explained in

Compare how 2 books explain cacheability →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Web APIs with ASP.NET Core. The section links point to the parts of the book it draws on.