AWS Developer DVA-C02 · Development with AWS Services · medium
An Amazon API Gateway REST API fronts a legacy product-catalog backend that takes 800 ms per query. Because 90% of incoming GET /products/{categoryId} requests query the same 50 popular categories, the developer enables API Gateway Stage Caching with a TTL of 300 seconds. During a flash sale, an administrator updates the price of an item in categoryId = 42 and needs to force a single immediate cache refresh (invalidation) for that specific request without flushing the entire stage cache. How does API Gateway support per-request cache invalidation?
Published · Last updated · checked before publication — how we verify questions
Options
Answer: C. Send the request with the Cache-Control: max-age=0 header (InvalidateCache)
API Gateway REST API stage caching lets a client invalidate a single cache entry by sending the request with the header Cache-Control: max-age=0. The gateway then skips the cached response, calls the backend, and stores the fresh result under the same cache key, so only that entry (here, the request for categoryId 42) is refreshed and the rest of the stage cache stays intact. This is controlled by the stage cache setting that requires authorization for cache invalidation. By default the caller needs execute-api:InvalidateCache permission in an IAM policy, or the setting can be relaxed so unauthorized callers may invalidate, which is risky because anyone could force backend load. The common trap is confusing this with flushing the entire stage cache from the console or the FlushStageCache API call, which clears every entry and would send all 50 popular categories back to the slow 800 ms backend. The question asks for a per-request approach, which is the header.
Why the other options are wrong
- A. Delete and recreate the entire API Gateway REST API and custom domain — Deleting and recreating the REST API and custom domain is a destructive redeployment that causes an outage and discards all configuration. It is not a cache invalidation mechanism and is far broader than a single-entry refresh.
- B. Send an HTTP DELETE request to the AWS X-Ray trace collector daemon — The AWS X-Ray daemon collects and forwards trace segments for observability. It has no interface for sending DELETE requests to manage API Gateway stage cache entries, so it cannot invalidate anything.
- D. Change the backend Lambda function runtime from nodejs20.x to python3.12 in SAM — Changing the Lambda runtime from Node.js to Python alters backend code execution, not the cache. Cached responses stay in API Gateway until the TTL expires or they are invalidated, so a runtime change would not refresh the cached price for categoryId 42.
More Development with AWS Services questions
- A customer-facing checkout API built on AWS Lambda (Java 21 runtime) experiences a 3.2-second cold-start latency spike…
- An AWS Lambda function polls an Amazon SQS standard queue via an Event Source Mapping with a batch size of 10…
- An order-fulfillment workflow coordinates 6 sequential and parallel steps: reserve inventory, charge credit card…
- Five different AWS Lambda functions written in Python 3.12 share the same 45 MB internal cryptography and…
- A photo-sharing platform stores private user photos in an Amazon S3 bucket (Block Public Access = ON). When an…
- A web application hosted on https://app.example.com makes an XMLHttpRequest / fetch() POST call (with a custom…
- A financial ledger uses Amazon SQS FIFO (First-In-First-Out) queues (orders.fifo) to guarantee strict message ordering…
- A developer is designing indexes for an Amazon DynamoDB Orders table whose base primary key is CustomerId (Partition…
All Development with AWS Services questions and the topic overview →
AWS and Amazon Web Services are trademarks of Amazon.com, Inc. PrepIQ Hub is not affiliated with, endorsed by, or sponsored by Amazon Web Services.