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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
れやか
September 21, 2025
Technology
2
1k
SSG の限界を破る、再ビルド不要なサイト
フロントエンドカンファレンス東京 2025で発表したスライドです。
れやか
September 21, 2025
Tweet
Share
Other Decks in Technology
See All in Technology
オープンウェイトのLLMリランカーを契約書で評価する / searchtechjp
sansan_randd
3
620
AIと新時代を切り拓く。これからのSREとメルカリIBISの挑戦
0gm
0
640
分析画面のクリック操作をそのままコード化 ! エンジニアとビジネスユーザーが共存するAI-ReadyなBI基盤
ikumi
0
130
データの整合性を保ちたいだけなんだ
shoheimitani
2
320
Bill One急成長の舞台裏 開発組織が直面した失敗と教訓
sansantech
PRO
1
160
データ民主化のための LLM 活用状況と課題紹介(IVRy の場合)
wxyzzz
2
630
月間数億レコードのアクセスログ基盤を無停止・低コストでAWS移行せよ!アプリケーションエンジニアのSREチャレンジ💪
miyamu
0
730
あたらしい上流工程の形。 0日導入からはじめるAI駆動PM
kumaiu
5
730
(金融庁共催)第4回金融データ活用チャレンジ勉強会資料
takumimukaiyama
0
110
AI推進者の視点で見る、Bill OneのAI活用の今
sansantech
PRO
2
320
Deno・Bunの標準機能やElysiaJSを使ったWebSocketサーバー実装 / ラーメン屋を貸し切ってLT会! IoTLT 2026新年会
you
PRO
0
220
入社1ヶ月でデータパイプライン講座を作った話
waiwai2111
1
210
Featured
See All Featured
sira's awesome portfolio website redesign presentation
elsirapls
0
140
My Coaching Mixtape
mlcsv
0
45
Technical Leadership for Architectural Decision Making
baasie
1
230
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
62
Accessibility Awareness
sabderemane
0
47
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
2k
Exploring anti-patterns in Rails
aemeredith
2
240
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
56
50k
Bash Introduction
62gerente
615
210k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
0
100
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