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.4k
Dangerを使ってPRを自動的にチェックする
jp_pancake
1
2.5k
Other Decks in Programming
See All in Programming
CSC509 Lecture 09
javiergs
PRO
0
110
推し活の ハイトラフィックに立ち向かう Railsとアーキテクチャ - Kaigi on Rails 2024
falcon8823
6
2.2k
讓數據說話:用 Python、Prometheus 和 Grafana 講故事
eddie
0
350
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
930
macOS でできる リアルタイム動画像処理
biacco42
7
2k
Googleのテストサイズを活用したテスト環境の構築
toms74209200
0
270
gopls を改造したら開発生産性が高まった
satorunooshie
8
240
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
7
2.8k
約9000個の自動テストの 時間を50分->10分に短縮 Flakyテストを1%以下に抑えた話
hatsu38
23
11k
詳細解説! ArrayListの仕組みと実装
yujisoftware
0
480
Outline View in SwiftUI
1024jp
1
170
/←このスケジュール表に立ち向かう フロントエンド開発戦略 / A front-end development strategy to tackle a single-slash schedule.
nrslib
1
590
Featured
See All Featured
Building an army of robots
kneath
302
42k
Making the Leap to Tech Lead
cromwellryan
132
8.9k
How to train your dragon (web standard)
notwaldorf
88
5.7k
GitHub's CSS Performance
jonrohan
1030
460k
Optimizing for Happiness
mojombo
376
69k
Being A Developer After 40
akosma
86
590k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.6k
The Language of Interfaces
destraynor
154
24k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Practical Orchestrator
shlominoach
186
10k
Facilitating Awesome Meetings
lara
49
6k
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!