Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
知っててうれしい HTTP キャッシュについて
Search
greendrop
December 12, 2024
Technology
400
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
知っててうれしい HTTP キャッシュについて
greendrop
December 12, 2024
More Decks by greendrop
See All by greendrop
gh skill コマンドで AI エージェントのスキルを一元管理・自動配布する
greendrop
0
39
GitHub Actions の設定を少しよくする
greendrop
0
48
リンクからモバイルアプリを起動する技術
greendrop
0
38
知っててうれしい SQL について
greendrop
0
350
知っててうれしい HTTP Cookie を使ったセッション管理について
greendrop
1
340
知っててうれしいリレーショナルデータベースについて
greendrop
0
300
スマホアプリエンジニアでない方へ向けた、スマホアプリ開発に関連するトピック
greendrop
0
280
知っててうれしい HTTP について
greendrop
0
380
知っててうれしい HTTP Cookie について
greendrop
0
350
Other Decks in Technology
See All in Technology
Amazon S3 Tablesに全部任せてみた結果——コンパクション/スナップショット管理は本当に手放せるか
shigeruoda
1
440
TinyGo 開発サイクルを高速化する:Go で作るエミュレータ入門
zozotech
PRO
1
150
AIとペアプロを始める。人とのペアプロをやめる。ペアプロの良さを改めて知る。もっと好きになった。 / Rediscovering Pair Programming
honyanya
1
310
Screen Lens - 今見てる画面を翻訳する
komagata
0
180
20260906 「AWS運用入門」著者が教える、運用業務への生成AI活用入門
masaruogura
0
260
Where Is JetBrains AI Heading- — Central CLI, Air Alpha, and the Agentic Development Stack
x5gtrn
PRO
0
150
深夜のクラウド懺悔室 1:29:300 or 1:0:0
kazzpapa3
1
220
ASTを使って影響範囲を特定する
nealle
0
130
HRC_Frontend_Conference_Fukuoka_2026.pdf
ts020
0
110
DEFCON_CHV_CTF_Write-up.pdf
bata_24
0
110
振り返りこそエンジニアの本領
negima
0
350
20260912_スクラムにジェネラリストは必要か
ryugen04
0
160
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
50
15k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
970
Crafting Experiences
bethany
1
310
The Cost Of JavaScript in 2023
addyosmani
55
10k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
67
58k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
The browser strikes back
jonoalderson
0
1.6k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
370
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
Leo the Paperboy
mayatellez
8
2.2k
Transcript
知っててうれしい HTTP キャッシュについて 2024/12/10 1
目次 HTTP キャッシュとは ヒューリスティックキャッシュ Expires または Cache-Control max-age If-Modified-Since ETag/If-None-Match
キャッシュしない まとめ 2
HTTP キャッシュとは HTTP キャッシュは、Web サーバーから取得したデータを一時的に保 存する仕組みです。 同じデータを再度取得する際に、キャッシュから取得することで、通 信量を削減し、応答速度を向上させることができます。 HTTP キャッシュとは
3
ヒューリスティックキャッシュ ヒューリスティックキャッシュは、サーバーからのレスポンスにキャ ッシュ期限が設定されていない場合に、ブラウザが自動的にキャッシ ュ期限を設定する仕組みです。 レスポンスヘッダーに Cache-Control: max-age=3600 などのキャッシュ 期限が設定されていない場合に、ブラウザが自動的にキャッシュ期限 を設定します。
ヒューリスティックキャッシュ 4
ヒューリスティックキャッシュ HTTP/1.1 200 OK Content-Type: text/html Date: Tue, 10 Dec
2024 00:00:00 GMT Last-Modified: Sun, 10 Dec 2023 00:00:00 GMT Date( レスポンス日時) と Last-Modified( リソース変更日時) の差分を 10 分の 1 にして、それがキャッシュ期限となります。 (2024/12/10 - 2023/12/10) / 10 = 0.1 年 2024/12/10 + 0.1 年までがキャッシュ期限 ヒューリスティックキャッシュ 5
Expires または Cache-Control max-age レスポンスヘッダーの Expires または Cache-Control max-age にキャ
ッシュの有効期限に設定できます。 Expires と Cache-Control max-age の両方が設定されている場合は、 Cache-Control max-age が優先されます。 Expires または Cache-Control max-age 6
Expires または Cache-Control max-age HTTP/1.1 200 OK Content-Type: text/html Date:
Tue, 10 Dec 2024 00:00:00 GMT Expires: Wed, 10 Dec 2025 00:00:00 GMT Cache-Control: max-age=31557600 レスポンス日時から 1 年間(31557600 秒) がキャッシュ期限 Expires または Cache-Control max-age 7
If-Modified-Since クライアントがリソースを取得する際に、サーバーに対してリソース の最終更新日時を伝えることができます。 サーバーは、リソースの最終更新日時とクライアントが伝えた最終更 新日時を比較し、リソースが更新されていない場合は 304 Not Modified を返します。 304
Not Modified は、サーバーからリソースを取得せず、クライアン トのキャッシュを使用することを示します。 If-Modified-Since 8
If-Modified-Since リクエスト GET /index.html HTTP/1.1 Host: example.com If-Modified-Since: Tue, 10
Dec 2024 00:00:00 GMT レスポンス HTTP/1.1 304 Not Modified Date: Tue, 10 Dec 2024 00:00:00 GMT If-Modified-Since 9
ETag/If-None-Match ETag は、リソースのハッシュ値を表す文字列で、リソースが更新され ると変更されます。 クライアントは、リソースの ETag をサーバーに伝えることができま す。 サーバーは、リソースの ETag
とクライアントが伝えた ETag を比較 し、リソースが更新されていない場合は 304 Not Modified を返しま す。 304 Not Modified は、サーバーからリソースを取得せず、クライアン トのキャッシュを使用することを示します。 ETag/If-None-Match 10
ETag/If-None-Match 初回レスポンス HTTP/1.1 200 OK Content-Type: text/html ETag: "abc123" ETag/If-None-Match
11
ETag/If-None-Match リクエスト GET /index.html HTTP/1.1 Host: example.com If-None-Match: "abc123" レスポンス
HTTP/1.1 304 Not Modified Date: Tue, 10 Dec 2024 00:00:00 GMT ETag/If-None-Match 12
キャッシュしない キャッシュを行わない場合は、レスポンスヘッダーに Cache-Control: no-store を設定します。 HTTP/1.1 200 OK Content-Type: text/html
Cache-Control: no-store キャッシュしない 13
まとめ HTTP キャッシュは、Web サーバーから取得したデータを一時的に保存する仕 組み ヒューリスティックキャッシュは、キャッシュ期限が設定されていない場合 に、ブラウザが自動的にキャッシュ期限を設定 Expires または Cache-Control
max-age でキャッシュの有効期限を設定 If-Modified-Since は、リソースの最終更新日時を伝え、304 Not Modified で キャッシュを使用 ETag/If-None-Match は、リソースの ETag を伝え、304 Not Modified でキャ ッシュを使用 キャッシュしない場合は、 Cache-Control: no-store レスポンスヘッダーを設定 まとめ 14
ご清聴ありがとうございました。 15