交付快取
CDN 快取頭規劃
選擇資源類型並得到 Cache-Control 建議。帶 hash 的檔案可以用長期 immutable;HTML 和私有 API 應重新驗證或禁止共享快取。
可用100/100
資源類型
檔名帶 hash 時可用一年 immutable。HTML 和登入態 API 不行。
方案只留在此瀏覽器,不會上傳。
建議回應頭
把 Cache-Control 配到 CDN 或源站對應路徑。
| 類型 | 匹配 | Cache-Control |
|---|---|---|
| 帶 hash 的 JS/CSS/圖片 | /assets/*.[hash].* | public, max-age=31536000, immutable |
| HTML 文件 | / | public, max-age=0, must-revalidate |
| 私有 API | /api/* | private, no-store |
| 字體 | /fonts/*.[hash].woff2 | public, max-age=31536000, immutable |
| 無 hash 圖片 | /images/* | public, max-age=86400, stale-while-revalidate=604800 |
| Sitemap XML | /sitemap*.xml | public, max-age=3600, stale-while-revalidate=86400 |