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
610
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
440
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
440
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
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
710
「Chatwork」Android版アプリを 支える単体テストの現在
okuzawats
0
180
KMP와 kotlinx.rpc로 서버와 클라이언트 동기화
kwakeuijin
0
140
From Translations to Multi Dimension Entities
alexanderschranz
2
130
Security_for_introducing_eBPF
kentatada
0
110
命名をリントする
chiroruxx
1
390
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
700
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
540
Jakarta EE meets AI
ivargrimstad
0
240
たのしいparse.y
ydah
3
120
急成長期の品質とスピードを両立するフロントエンド技術基盤
soarteclab
0
930
20年もののレガシープロダクトに 0からPHPStanを入れるまで / phpcon2024
hirobe1999
0
430
Featured
See All Featured
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Being A Developer After 40
akosma
87
590k
Agile that works and the tools we love
rasmusluckow
328
21k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Done Done
chrislema
181
16k
Facilitating Awesome Meetings
lara
50
6.1k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
A Tale of Four Properties
chriscoyier
157
23k
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!