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
670
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
Click-free releases & the making of a CLI app
oheyadam
2
110
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
470
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
110
ローコードSaaSのUXを向上させるためのTypeScript
taro28
1
610
C++でシェーダを書く
fadis
6
4.1k
CSC509 Lecture 12
javiergs
PRO
0
160
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
6
1.7k
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
120
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
330
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.3k
Featured
See All Featured
What's new in Ruby 2.0
geeforr
343
31k
Agile that works and the tools we love
rasmusluckow
327
21k
We Have a Design System, Now What?
morganepeng
50
7.2k
Side Projects
sachag
452
42k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Facilitating Awesome Meetings
lara
50
6.1k
Building Adaptive Systems
keathley
38
2.3k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
How GitHub (no longer) Works
holman
310
140k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
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!