Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
SSG の限界を破る、再ビルド不要なサイト
Search
れやか
September 21, 2025
Technology
2
620
SSG の限界を破る、再ビルド不要なサイト
フロントエンドカンファレンス東京 2025で発表したスライドです。
れやか
September 21, 2025
Tweet
Share
Other Decks in Technology
See All in Technology
『OCI で学ぶクラウドネイティブ 実践 × 理論ガイド』 書籍概要
oracle4engineer
PRO
3
210
JAZUG 15周年記念 × JAT「AI Agent開発者必見:"今"のOracle技術で拡張するAzure × OCIの共存アーキテクチャ」
shisyu_gaku
1
160
成長自己責任時代のあるきかた/How to navigate the era of personal responsibility for growth
kwappa
4
320
Adapty_東京AI祭ハッカソン2025ピッチスライド
shinoyamada
0
280
そのWAFのブロック、どう活かす? サービスを守るための実践的多層防御と思考法 / WAF blocks defense decision
kaminashi
0
190
[Codex Meetup Japan #1] Codex-Powered Mobile Apps Development
korodroid
2
460
Modern_Data_Stack最新動向クイズ_買収_AI_激動の2025年_.pdf
sagara
0
240
Wasmのエコシステムを使った ツール作成方法
askua
0
130
Performance Insights 廃止から Database Insights 利用へ/transition-from-performance-insights-to-database-insights
emiki
0
240
How to achieve interoperable digital identity across Asian countries
fujie
0
150
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
11
80k
OCI Network Firewall 概要
oracle4engineer
PRO
2
7.9k
Featured
See All Featured
Leading Effective Engineering Teams in the AI Era
addyosmani
3
350
Visualization
eitanlees
149
16k
Building Better People: How to give real-time feedback that sticks.
wjessup
369
20k
Raft: Consensus for Rubyists
vanstee
139
7.1k
Bash Introduction
62gerente
615
210k
Done Done
chrislema
185
16k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
9
590
GraphQLとの向き合い方2022年版
quramy
49
14k
Optimizing for Happiness
mojombo
379
70k
Faster Mobile Websites
deanohume
310
31k
Git: the NoSQL Database
bkeepers
PRO
431
66k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
30
2.9k
Transcript
SSG の限界を破る、 再ビルド不要なサイト れやか (@reyalka_dev) 1
自己紹介 れやか (reyalka) 学生です Astroが好き 2
SSG とは、 Astroのこと 3
Astro v5.10 で追加された Live Content Collections のお話 4
1. Astro Content Collections について 5
Live Content Collections は Content Collections の拡張 まずは、Content Collections について
1. Astro Content Collectionsについて 6
Content Collections は、コンテンツを楽に・安全に扱えるようにする 機能 以下のような機能が存在する Local File や 外部 API
からのコンテンツ取得 Markdown, HTML, JSON, YAML など様々なフォーマットに対応 Zod によるスキーマバリデーション Typescript の型生成 1. Astro Content Collectionsについて 7
(例) Markdown で書いたブログ記事のコンテンツを管理する場合 const blog = defineCollection({ // 1. content
loaderの定義 loader: glob({ base: "./src/data/blog", pattern: "**/*.md" }), // 2. スキーマバリデーション schema: z.object({ title: z.string(), description: z.string().optional(), pubDate: z.date(), }), }); export const collections = { blog }; 1. Astro Content Collectionsについて src/content/config.ts 8
(例) Markdown で書いたブログ記事のコンテンツを管理する場合 // 3. コンテンツの取得 const allPosts = await
getCollection("blog"); // すべてのコンテンツ const post = await getEntry("blog", "<post-id>"); // 特定のコンテンツ このとき、型補完が効くので便利 1. Astro Content Collectionsについて 9
2. 従来の Content Collections の弱点 10
コンテンツはビルドごとに反映される .astro ファイル Build HTML ファイル 静的なコンテンツ しかし、この方法だとコンテンツを更新する度にビルドが必要になる →リアルタイム性が求められるコンテンツには不向き (例:ニュース、天気予報、株価情報など)
2. 従来の Content Collections の問題点 11
だったら、SSR すれば? →「静的=SSG」「動的=SSR」 2. 従来の Content Collections の問題点 12
双方にメリットがある SSG: 生のHTMLを配信できる SSR: 常に最新の情報を提供できる SSG と SSR の良いとこ取りができたらな... 2.
従来の Content Collections の問題点 13
そこで、Live Content Collections SSR SSG 2. 従来の Content Collections の問題点
14
3. Live Content Collections とは? 15
ビルド時ではなく、リクエスト時にコンテンツを取得してページを生 成する コンテンツストア(API 等) サーバー ユーザー コンテンツストア(API 等) サーバー ユーザー
リクエストを送信 コンテンツの取得を要求 コンテンツデータ返却 ページ生成処理 ページHTML を返却 しかも、これは ページの一部分だけ 3. Live Content Collections とは? 16
<section> <h1>最新のニュース</h1> // ここは静的 (= 生のHTML = SSG) <img src="..."
alt="..." /> // ここも静的 <LatestNews server:defer /> // ここは動的 (= SSR) </section> 3. Live Content Collections とは? 17
毎回データを取得するので、常に最新の情報 を提供できる しかも、Astro のコンテンツ管理機能もつい てくる 3. Live Content Collections とは?
18
(例) 外部 API にリクエストして、データを取得する const news = defineLiveCollection({ // 1.
content loaderの定義(データ取得部分は省略) loader: liveFeedLoader("https://example.com/api/news"), // 2. スキーマバリデーション schema: z.object({ id: z.string(), title: z.string(), author: z.string().optional(), body: z.string(), }), }); export const collections = { news }; 3. Live Content Collections とは? src/live.config.ts 19
(例) 外部 API にリクエストして、データを取得する // 3. コンテンツの取得 const { entries,
error } = await getLiveCollection("news"); // すべてのコンテンツ if (error) { ... } // エラーハンドリング const { entry, error } = await getLiveEntry("news", "<news-id>"); // 特定のコンテンツ if (error) { ... } // エラーハンドリング もちろん、型補完も効く 3. Live Content Collections とは? 20
コンテンツストア(API 等) サーバー ユーザー コンテンツストア(API 等) サーバー ユーザー リクエストを送信 コンテンツの取得を要求
コンテンツデータ返却 ページ生成処理 ページHTML を返却 3. Live Content Collections とは? 21
ユーザーからリクエストが来るたび にコンテンツを取得するのは、負荷 が高いのでは? → cacheHint で解決 3. Live Content Collections
とは? 22
4. cacheHint で負荷を軽減 23
Astro は、負荷を軽減するために、 cacheHint を導入 適切なキャッシュ方法を教えてくれる cacheHint は、Loader 側が設 定する (例)
Loader が cacheHint を提供している場合 const { entry: post, error, cacheHint, } = await getLiveEntry("blog", "<post-id>"); Astro.response.headers.set("Last-Modified", cacheHint.lastModified.toString()); 4. cacheHintで負荷を軽減 24
export interface CacheHint { /** Cache tags */ tags?: Array<string>;
/** Maximum age of the response in seconds */ maxAge?: number; /** Last modified time of the content */ lastModified?: Date; } 4. cacheHintで負荷を軽減 25
cacheHint で提供する情報は Loader 側に委ねられる 将来的には Astro 内部で自動的に 実装されるかも? 4. cacheHintで負荷を軽減
26
5. ISR との比較 27
Live Content Collections と似たような仕組み → ISR 5. ISRとの比較 28
Next.js の ISR Astro の Live Content Collections 検証するかは開発者次 第
自動でコンテンツを検証 ビルドした結果を保存 しておく リクエストが来るたびにコンテンツを取得 して、ページを生成する revalidate の秒数ごと に再生成 毎回取得するので、常に最新の情報を提供 できる 5. ISRとの比較 29
5. まとめ 30
Live Content Collections は、SSG と SSR の 良いとこ取り 動的なコンテンツを扱うための新しい選択肢 となりうる
5. まとめ 31