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
iOS の HTTP キャッシュについて
Search
Satoshi Hachiya
October 09, 2018
Programming
3
600
iOS の HTTP キャッシュについて
potatotips #55 (iOS/Android開発Tips共有会)
https://potatotips.connpass.com/event/100763/
Satoshi Hachiya
October 09, 2018
Tweet
Share
More Decks by Satoshi Hachiya
See All by Satoshi Hachiya
花嫁アプリを作った
jp_pancake
1
430
try! ReactorKit
jp_pancake
1
680
QR Code Recognition on iOS 11
jp_pancake
1
1.2k
WWDC Pre Party 2018 at Ebisu
jp_pancake
4
3.2k
try! Swift Tokyo 2018 Report
jp_pancake
1
430
try! Swift Tokyo 2018 Day 1 Opening
jp_pancake
0
810
What is `Swifty`?
jp_pancake
2
1.2k
danger-swift
jp_pancake
2
1.5k
Dangerを使ってPRを自動的にチェックする
jp_pancake
1
2.5k
Other Decks in Programming
See All in Programming
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
120
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
250
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
130
CSC509 Lecture 11
javiergs
PRO
0
180
Jakarta EE meets AI
ivargrimstad
0
620
Functional Event Sourcing using Sekiban
tomohisa
0
100
色々なIaCツールを実際に触って比較してみる
iriikeita
0
330
TypeScript Graph でコードレビューの心理的障壁を乗り越える
ysk8hori
2
1.2k
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1.2k
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
1k
Featured
See All Featured
Happy Clients
brianwarren
98
6.7k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
GraphQLとの向き合い方2022年版
quramy
43
13k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Facilitating Awesome Meetings
lara
50
6.1k
Building Applications with DynamoDB
mza
90
6.1k
The Cult of Friendly URLs
andyhume
78
6k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Docker and Python
trallard
40
3.1k
Transcript
iOS ͷ HTTP Ωϟογϡʹ͍ͭͯ 2018.10.9 - potatotips #55 Satoshi Hachiya
(@jpmartha_jp)
Satoshi Hachiya (@jpmartha_jp)
ࠓͷ • API ͷϨεϙϯεͰߋ৽༰͕͙͢ʹө͞Εͳ͔ͬͨ • iOS ଆͷܿനΛূ໌͢ΔͨΊʹࢼͨ͠খωλ • ͙͢͏Α͏ͳωλͰͳ͍͕Կ͔͋ͬͨͱ͖ͷࢀߟʹ
HTTP Ωϟογϡ https://developer.mozilla.org/ja/docs/Web/HTTP/Caching ʮաڈʹऔಘͨ͠ϦιʔεΛ࠶༻͢ΔͱɺΣϒαΠτΞϓ ϦέʔγϣϯͷύϑΥʔϚϯε͕େ্͖͘͢ΔͰ͠ΐ͏ɻΣ ϒΩϟογϡԆωοτϫʔΫͷτϥϑΟοΫΛݮͯ͠ɺ ϦιʔεΛදࣔ͢ΔͨΊʹඞཁͳ࣌ؒॖ͠·͢ɻ HTTP ΩϟογϡΛ༻͢ΔͱɺΣϒαΠτͷԠੑ͕ߴ·Γ· ͢ɻʯ
https://developers.google.com/web/fundamentals/performance/ optimizing-content-efficiency/http-caching?hl=ja ʮωοτϫʔΫܦ༝ͰใΛऔಘ͢Δʹ࣌ؒίετ͔͔Γ ·͢ɻϨεϙϯε͕େ͖͍ͱɺΫϥΠΞϯτͱαʔόʔؒͷϥ ϯυτϦοϓΛԿ܁Γฦ͢ඞཁ͕͋ΔͨΊɺϨεϙϯε͕ར ༻ՄೳͱͳͬͯϒϥβͰॲཧͰ͖ΔΑ͏ʹͳΔ·Ͱ͕͔͔࣌ؒ Γ·͢ɻ͞ΒʹɺϢʔβʔଆͰσʔλͷ௨৴ίετ͕ൃੜ͠· ͢ɻͦͷͨΊɺલʹऔಘͨ͠ϦιʔεΛΩϟογϡʹอଘͯ͠࠶ ༻Ͱ͖Δ͜ͱɺύϑΥʔϚϯεΛ࠷దԽ͢Δ্Ͱඇৗʹॏཁ Ͱ͢ɻʯ
iOS Ͱ ΩϟογϡΛಡΈࠐ·ͳ͍ํ๏ άάΕ͙͢ݟ͔ͭΔ
CachePolicy Λมߋ
CachePolicy Λมߋ
ͪͳΈʹ .reloadIgnoringLocalAndRemoteCacheData ࣮͞Ε͍ͯͳ͍ʂ
None
ͦΕ͓͖ͯ͞
CachePolicy ͷઃఆ͚ͩͰ ΩϟογϡΛಡΈࠐ·ͳ͍͕ ! อଘ͢Δ
γϛϡϨʔλʔͰΩϟογϡΛ֬ೝ
อଘॴ /Library/Developer/CoreSimulator/Devices/xxx/data/ Containers/Data/Application/xxx/Library/Caches/ com.example.bundleid ʹ͋ͬͨ
cache.db Λͷͧ͘ • DB Browser for SQLite
͜Μͳײ͡
ΩϟογϡΛಡΈࠐ·ͳ͍ ʢΆ͍ʣ͠ɺ͜ΕͰΑ͘ͳ͍ʁ
ΕͨΒ·͍ͣΩϟογϡอଘ͠ͳ͍ • ॏཁใͷ࿙͍͑ʹͭͳ͕ΔεϚϗΞϓϦͷΩϟογϡͱ ରࡦɿhttps://www.lac.co.jp/lacwatch/people/ 20180228_001581.html • ͨͩͪ͜͠ΒͰհ͞Ε͍ͯΔํ๏ͷ͏ͪɺCapacity = 0 ͩͱ
ͦΕҎ߱ΩϟογϡΛར༻Ͱ͖ͳ͘ͳΓͦ͏
ΩϟογϡΛಡΈࠐ·ͳ͍͠ อଘ͠ͳ͍ํ๏
None
configuration.urlCache = nil
·ͨ .ephemeral
ͨͩ͠ɺ͍ͣΕ طଘͷΩϟογϡΔ
ΩϟογϡΛআ͢Δํ๏ ͯ͢আ ૂ͍ܸͪʢࣦഊʣ session.configuration.urlCache?.removeCachedResponse(for: urlRequest)
None
·ͱΊ • લఏɿΩϟογϡύϑΥʔϚϯε্ʹඞཁ • requestCachePolicy Λมߋ͚ͨͩ͠ͰΩϟογϡΛอଘ͢Δ • urlCache = nil
ʹมߋͯ͠طଘͷΩϟογϡΔ ʢ.ephemeral ʣ • removeAllCachedResponses Ͱͯ͢আ͢Δ • Capacity = 0 ʹ͢ΔͱͦΕҎ߱ΩϟογϡΛར༻Ͱ͖ͳ͍ʁ
ࢀߟ • URL Loading Systemɿhttps://developer.apple.com/ documentation/foundation/url_loading_system • Ωϟογϡͷڍಈɿhttps://developer.apple.com/ documentation/foundation/nsurlrequest/cachepolicy/ useprotocolcachepolicy
• ΩϟογϡͷΞΫηεɿhttps://developer.apple.com/ documentation/foundation/url_loading_system/ accessing_cached_data
Thanks!