8.5 API Gateway
What is API Gateway
Amazon API Gateway is a fully managed service that makes it easy for developers to publish, maintain, monitor, and secure APIs at any scale. With a few clicks in the AWS management console, you can create an API that acts as a "front door" for applications to access data, business logic, or functionality from your back-end services, such as applications running on AWS EC2, code running on AWS Lambda, or any web application.
What is API Caching
You can enable API caching in Amazon API Gateway to cache your endpoint's response. With caching, you can reduce the number of calls made to your endpoint and also improve the latency of the requests to your API. When you enable caching for a stage, API Gateway caches responses from your endpoint for a specified time-to-live (TTL) period, in seconds. API Gateway then response from the cache instead of making a request to your endpoint.
What can API Gateway Do
Low cost & efficient
Scales effortlessly
You can throttle requests to prevent attacks
Connect to CloudWatch to log all requests
Same Origin Policy
In computing, the same-origin policy is an important concept in the web application security model. Under the policy, a web browser permits scripts contained in a first web page to access data in a second web page, but only if both web pages have the same origin (same domain name).
Cross-Origin Resource Sharing (CORS)
This is one way the server at the other end, not the client code in the browser, can relax the Same Origin Policy.
CORS is a mechanism that allows restricted resources (e.g. fonts) on a web page to be requested from another domain outside the domain from which the first resource was served.
When you trouble-shooting with API Gateway, you may encounter an Error which is "Origin policy cannot be read at the remote resources?". You need to enable CORS on API Gateway.
Exam Tips
Remember what API gateway is at a high level.
API Gateway has caching capability to increase performance.
API Gateway is low cost and scales automatically.
You can throttle API Gateway to prevent attacks.
You can log results to CloudWatch.
If you are using JavaScript/Ajax that uses multiple domains with API Gateway, ensure that you have enabled CORS on API Gateway.
Last updated
Was this helpful?