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
420
try! ReactorKit
jp_pancake
1
660
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
標準ライブラリの動向とイテレータのパフォーマンス
makki_d
3
200
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
0
170
Re:PandasAI:生成AIがデータ分析業務にもたらすパラダイムシフト【増補改訂版】
negi111111
1
900
Iteratorでページネーションを実現する
sonatard
3
710
Modern Functional Fluent CFML REST by Luis Majano
ortus24
0
140
WEBアプリケーションにおけるAWS Lambdaを用いた大規模な非同期処理の実践
delhi09
PRO
7
4.1k
Rails 8 Frontend: 10 commandments & 7 deadly sins in 2025
yshmarov
1
630
4年間変わらなかった YOUTRUSTのアーキテクチャ
daiki1003
1
580
Infrastructure as Code でセキュリティを楽にしよう!
konokenj
6
1.4k
Vue :: Better Testing 2024
up1
1
400
データサイエンスのフルサイクル開発を実現する機械学習パイプライン
xcnkx
2
500
色んなオートローダーを覗き見る #phpcon_okinawa
o0h
PRO
5
390
Featured
See All Featured
Designing for Performance
lara
604
68k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
46
4.9k
We Have a Design System, Now What?
morganepeng
49
7.2k
Infographics Made Easy
chrislema
239
18k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
92
16k
Imperfection Machines: The Place of Print at Facebook
scottboms
264
13k
Creatively Recalculating Your Daily Design Routine
revolveconf
217
12k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
32k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
664
120k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
27
1.9k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.7k
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!