Last updated on May 3, 2021
To invalidate an existing cache entry of a request and retrieve the latest data from the integration endpoint, one must send the request together with the Cache-Control: max-age=0 header. If the recipient is authorized to communicate directly to the integration endpoint, then the integration endpoint will respond with the latest data for the request. This also replaces the existing cache entry with the new response.
The IAM Policy that grants a client to invalidate the cache follows:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"execute-api:InvalidateCache"
],
"Resource": [ "arn:aws:execute-api:region:account-id:api-id/stage-name/GET/resource-path-specifier"
]
}
]
}
An alternative option for requiring authorization, aside from using the policy above, is to place a checkmark on Require Authorization checkbox. This checkbox can be seen in the Settings tab of your Deployment stage, after you enable API caching.
If you have enabled caching and authorization, you can also configure how unauthorized requests are handled:
- Fail the request with 403 status code: returns a 403 Unauthorized response.
- Ignore cache control header; Add a warning in response header: process the request and add a warning header in the response.
- Ignore cache control header: process the request and do not add a warning header in the response.
Note: If you are studying for the AWS Certified Advanced Networking Specialty exam, we highly recommend that you take our AWS Certified Advanced Networking – Specialty Practice Exams and read our Advanced Networking Specialty exam study guide.