This commit is contained in:
Rijn committed 2026-10-25 20:30:53 +00:00
1 parent 1267a7b624
commit fd0cce4740
1 file changed
+47 -5
+47 -5
View File
@@ -5,17 +5,19 @@
- Video Streaming - Video Streaming
- Web Sockets - Web Sockets
## Benefits ### Benefits
- [[_CloudFront|CloudFront]] can be fronted with [[AWS WAF]] for OWASP's top 10 protection. - [[_CloudFront|CloudFront]] can be fronted with [[AWS WAF]] for OWASP's top 10 protection.
- [[_CloudFront|CloudFront]] can stream [[Videos On Demand]] using [[ISS Microsoft Smooth Streaming]] - [[_CloudFront|CloudFront]] can stream [[Videos On Demand]] using [[ISS Microsoft Smooth Streaming]]
## Core components ### Core components
**Origin**: Location where all original files are located. Examples include: S3, EC2, ELB, Route53. **Origin**: Location where all original files are located. Examples include: S3, EC2, ELB, Route53.
**Edge Locations**: Compute located strategically close to end users. **Edge Locations**: Compute located strategically close to end users.
**Regional Caches**: Compute located in board geographical locations to speed up requests for edge locations. **Regional Caches**: Compute located in board geographical locations to speed up requests for edge locations.
**Distribution**: A collection of Edge locations and Regional Cache that defines how cached content should behave. **Distribution**: A collection of Edge locations and Regional Cache that defines how cached content should behave.
## Running Code
## Stages where [[Lambda@Edge]] and [[CloudFront Functions]] can trigger ### Stages where [[Lambda@Edge]] and [[CloudFront Functions]] can trigger
The order that the functions trigger within CloudFront is: The order that the functions trigger within CloudFront is:
| Order | Stage | L@E | CF Fns | Description | Example Use Cases | | Order | Stage | L@E | CF Fns | Description | Example Use Cases |
|--|---|---|---|---|--| |--|---|---|---|---|--|
@@ -36,7 +38,7 @@ sequenceDiagram
Edge->>Viewer: Viewer Response Edge->>Viewer: Viewer Response
``` ```
## Difference between [[Lambda@Edge]] and [[CloudFront Functions]] ### Difference between [[Lambda@Edge]] and [[CloudFront Functions]]
| | CF Fns | L@E | | | CF Fns | L@E |
|---|---|---| |---|---|---|
| Programming Languages | JavaScript (ECMAScript 5.1) | Node.JS and Python | | Programming Languages | JavaScript (ECMAScript 5.1) | Node.JS and Python |
@@ -51,3 +53,43 @@ sequenceDiagram
| Functions logging and metrics | ✔️ | ✔️ | | Functions logging and metrics | ✔️ | ✔️ |
| Pricing | Cheaper. Free tier available; charged pre request. | More expensive. Charged per request & function duration. | | Pricing | Cheaper. Free tier available; charged pre request. | More expensive. Charged per request & function duration. |
## CloudFront Origin
It's the source where CloudFront will send requests.
### CloudFront Origin Groups
It allows you to group a **primary** and **secondary origin** together as a destination for requests to enable high availability and fault tolerance.
The **Primary Origin** is where **all** the requests will be sent.
The **Secondary Origin** is where the requests will be sent if the **Primary Origin** is **not available**. It will act like a **failover** origin.
The **failover** criteria is based on **HTTP Status Codes**: 400, 403, 404, 416, 500, 502, 503, 504.
CloudFront will failover on: `GET`, `HEAD`, and `OPTION` requests.
CloudFront will NOT failover on: `PUT`, `POST`, `PATCH`, and `DELETE`.
## CloudFront Caching Policy
### Cache Key
The **Cache Key** is a unique identifier for every object in the cache and determines whether a viewer request results in a cache hit.
A cache hit occurs when a viewer request generates the same **Cache Key** as a prior request and the object for that cache key is in the edge location's cache.
The more people hit the cache, the better the application performance will be.
### Cache Policy
A **Cache Policy** determines the **Cache Key**.
AWS has managed **Cache Policies** for use:
- `Amplify`
- `CachingDisabled`
- `CachingOptimized`
- `CachingOptimizedForUncompressedObjects`
- `Elemental-MediaPackage`
You can make your own **Caching Policy**:
- **TTL Settings**:
- **Minimum** / **Maximum** **TTL**: min / max time to hold the file in the cache.
- **Default TTL**: default time to hold a file in the cache.
- **Cache Key Settings**:
- **Headers**: which headers are a part of the **Cache Key**.
- **Cookies**: which cookies are a part of the **Cache Key**.
- **Query String**: which query string parameters are a part of the **Cache Key**.
- **Compression Support**: What compression format is part of the **Cache Key**.