liveBook · Manning

Intermediate caching

As explained in Building Web APIs with ASP.NET Core

Intermediate caching is a caching technique in which a proxy or content-distribution service between a client and origin server stores and serves reusable responses.

Intermediate caching stores reusable HTTP responses in a proxy or content-delivery service between clients and the origin server. The proxy or CDN can serve later requests directly, using the same HTTP header rules that govern client-side caching. section 3.1.3 section 8.1

For a RESTful API, apply it to frequently accessed GET endpoints, especially requests using default parameters. Static sites may rely heavily on browser and CDN caching, while dynamic sites can combine intermediate response caching with server-side caching for expensive database work. section 8.1

A practical caching decision follows these considerations:

  • Cache at the highest level the client and application behavior can safely support. section 8.1
  • Use HTTP response headers to control reusable responses across clients and intermediate services. section 3.1.3
  • Treat client-specific or permission-specific requests carefully; server-side or distributed caching may better relieve database load when responses vary. section 8.1
// ...
 
[HttpGet(Name = "GetBoardGames")]
[ResponseCache(Location = ResponseCacheLocation.Any, Duration = 60)]
public IEnumerable<BoardGame> Get()
 
// ...

The board-game API marks its GET endpoint as cacheable for any location with a 60-second duration, providing a concrete ASP.NET Core response-caching configuration. section 3.1.3

How Building Web APIs with ASP.NET Core covers it

How deep it goes
Defines proxy and CDN placement, explains HTTP-header behavior, and demonstrates a 60-second ASP.NET Core endpoint policy.
Examples
Uses the MyBGList board-game GET endpoint, static websites, dynamic websites, default-parameter requests, and CDN delivery.
What you can do after
Operate/configure ASP.NET Core response caching for selected GET endpoints and reason about CDN placement for reusable responses.
How it connects
Connects HTTP response caching with client-side caching, server-side caching, proxies, CDNs, and distributed caching.

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.