Cloudflare Cache Rules:什麼該快取,什麼要保持動態
Cloudflare Cache Rules 是 zone 層的快取政策:用 request expression 決定哪些內容 eligible for cache、Edge TTL/Browser TTL 怎麼算、cache key 包哪些維度,以及遇到 stale、ETag、purge 時怎麼處理。它適合管理 CDN 快取規則;Worker Cache API 則適合程式化存取。
Cloudflare Cache Rules 是 zone 層的快取政策:用 request expression 決定哪些內容 eligible for cache、Edge TTL/Browser TTL 怎麼算、cache key 包哪些維度,以及遇到 stale、ETag、purge 時怎麼處理。它適合管理 CDN 快取規則;Worker Cache API 則適合程式化存取。
Cloudflare Images 有兩條路:把 R2/S3/origin 圖片拿來做 edge transformations,或直接把圖片存進 Images 再用 variant delivery。前者按 unique transformations 看成本,後者還要看 stored 和 delivered images。
Smart Shield 是 Cloudflare 的 origin protection bundle:用 Smart Tiered Cache、connection reuse、Argo Smart Routing、Regional Tiered Cache、Cache Reserve、Health Checks 和 Dedicated CDN Egress IPs,減少打到 origin 的 request 與 connection。
第五講從 SM、warp 與記憶體階層解釋 GPU,再用低精度、fusion、recomputation、coalescing 與 tiling 統一常見優化;FlashAttention 正是這些原則在 attention 上的組合。
第六講把 GPU 原理落到 kernel:benchmark 看不同尺寸如何縮放,profiler 看實際呼叫與時間,再以 Triton 實作 GeLU、softmax、reduction 與 tiled matmul;快的前提是先量對。
第二講把模型訓練還原成 tensor、FLOPs、bytes 與時間:用 einops 管維度,以 arithmetic intensity 和 roofline 判斷瓶頸,再用 gradient accumulation 與 activation checkpointing 交換運算和記憶體。
CS107 第 25 講用精簡投影片建立 cache 的核心模型:記憶體存取成本不均,較小且較快的層級保存可能再次使用的資料,而 temporal 與 spatial locality 決定程式能否受益。
RAG 系統的成本來自 LLM token、Embedding API、向量搜尋。每個環節都有可以壓成本的地方,但要確認優化沒有犧牲太多品質。
快取不只能比對完全一樣的查詢,語義相近的問題也能命中快取,省下整個 RAG pipeline 的執行。