Microsoft Certified: Azure Developer Associate (AZ-204)Monitor, troubleshoot, and optimize Azure solutionsMedium
A retail company uses Azure API Management (APIM) to expose product catalog APIs to its mobile application. The company wants to implement a robust caching mechanism at the API Gateway level to reduce the load on backend services and improve response times for frequently requested product data. The caching solution must support invalidation when product data changes in the backend. Which APIM caching policy should be configured to meet these requirements?
- Acache-lookup and cache-store with never-expire
- Bcache-lookup and cache-store with fixed duration
- Ccache-lookup and cache-store with conditional caching
- Dcache-lookup only
Show answer & explanationAnswer & explanation
Correct answer: C. cache-lookup and cache-store with conditional caching
Conditional caching with `cache-lookup` and `cache-store` policies allows APIM to store responses and revalidate them with the backend using ETag or Last-Modified headers. This ensures that the cache is invalidated and updated when the backend data changes, meeting the requirement for invalidation.
Why the other options are wrong
- A. Never-expire caching would mean the cache is never updated, leading to stale data when the backend changes.
- B. Fixed duration caching does not support invalidation based on backend data changes; it only expires after a set time.
- D. Only `cache-lookup` would check the cache but not store new responses, making the caching mechanism ineffective for improving performance over time.
APIM Conditional Caching
A caching strategy in Azure API Management that uses HTTP headers like ETag and Last-Modified to revalidate cached responses with the backend, ensuring cache invalidation when data changes.
- Reduces backend load and improves response times.
- Supports automatic cache invalidation on data changes.
- Requires `cache-lookup` and `cache-store` policies.
Memory trick: Cache with conditions, keep data current!