105
Effective Networking with Swift and iOS 8

Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Effective Networkingwith Swift and iOS 8

Page 2: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Ben Scheirman@subdigital

Page 3: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

ChaiOne

Page 4: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache
Page 5: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Agenda

• Old and Crusty NSURLConnection

• New Hotness

• Live Demos !

• HTTP

• Caching

• Bonus Round: API Tips

NSURLConnection

Page 6: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

NSURLConnection

Invented for Safari ~2000

Made public in 2003Poor separation of settings, config, cache

Page 7: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache
Page 8: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache
Page 9: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

NSURLConnection was replaced by NSURLSession in iOS 7

Page 10: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

NSURLSession

Page 11: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Still use NSURLRequestConfigurable Container (isolation w/ 3rd party libraries)

Improved auth

Rich Callbacks

Page 12: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache
Page 13: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache
Page 14: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

The New Family

Page 15: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

NSURLSessionConfiguration

NSURLSession

NSURLSessionTask

NSURLSessionDelegate

Page 16: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Start withNSURLSessionConfiguration

Page 17: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Default Sessions

+ defaultSessionConfiguration

Page 18: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Ephemeral Sessions

+ ephemeralSessionConfiguration

Page 19: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Ephemeral Sessions

+ ephemeralSessionConfiguration

?

Page 20: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

"private browsing"

Page 21: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Background Sessions

+ backgroundSessionConfiguration:

Page 22: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Background Sessions

+ backgroundSessionConfiguration:

• Takes an NSString identifier

• Causes uploads / downloads to occur in background

Page 23: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Customize it further

All of these class methods return a copy, tweak from there...

Page 24: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Well, what can you do with it?

Page 25: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Set a default header

var config = NSURLSessionConfiguration.defaultSessionConfiguration()

config.HTTPAdditionalHeaders = [ "auth_token" : "1234abcd" ]

Page 26: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Mark Requests as low-priority

config.discretionary = true

• Note: This has benefits, such as retrying when connection terminates, avoiding request if user is low on battery, or if Wi-Fi performance is not good enough.

Page 27: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Disable Cellular

config.allowsCellular = false

Page 28: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Set custom caching behavior

config.URLCache = MyCustomCache()config.requestCachePolicy = NSURLRequestReturnCacheDataElseLoad

Page 29: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Inject your own custom protocols!

Page 30: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

ben://awww.yeah

Page 31: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

(actually quite useful for mocking requests)

Page 32: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Next Step: build an NSURLSession to make

reuqests

Page 33: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

var session = NSURLSession(configuration: config)

Page 34: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

var session = NSURLSession(configuration: config)

or with a delegate...

var delegate: NSURLSessionDelegate = selfvar session = NSURLSession(configuration: config, delegate: delegate, delegateQueue: NSOperationQueue.mainQueue())

Page 35: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

NSURLSession

• Construct without the delegate if you want to use block callbacks

• Construct with a delegate for advanced control (or background sessions)

• If you pass completion handler blocks, delegate methods are not called

Page 36: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

NSURLSessionTask

Page 37: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache
Page 38: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

NSURLSessionDataTask

• Represents GET, PUT, POST, DELETE

• Handle Completion Callback

• If error is present, request failed

Page 39: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

What Constitutes an Error?

• Connection failed

• Timeouts

• Host invalid

• Bad URL

• Too many redirects

• ... dozens more (check URL Loading System Error Codes)

Page 40: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

NSURLSessionDownloadTask

• Downloading a file / resource

• Streams to disk

• Useful when size is large and can't fit in memory

• Temp file path is provided in completion block

• MUST move it somewhere if you want it to stick around

Page 41: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Building a simple GET Request• Build an instance of NSURLSessionDataTask

• (optionally) give it a block callback*

• Call resume

Page 42: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

var config = NSURLSessionConfiguration.defaultSessionConfiguration()var session = NSURLSession(configuration: config)

Page 43: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

var config = NSURLSessionConfiguration.defaultSessionConfiguration()var session = NSURLSession(configuration: config)

var url = NSURL(string: "https://www.nsscreencast.com/api/episodes.json")

Page 44: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

var config = NSURLSessionConfiguration.defaultSessionConfiguration()var session = NSURLSession(configuration: config)

var url = NSURL(string: "https://www.nsscreencast.com/api/episodes.json")

var task = session.dataTaskWithURL(url) { (let data, let response, let error) in // ...}

Page 45: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

var config = NSURLSessionConfiguration.defaultSessionConfiguration()var session = NSURLSession(configuration: config)

var url = NSURL(string: "https://www.nsscreencast.com/api/episodes.json")

var task = session.dataTaskWithURL(url) { (let data, let response, let error) in // ...}

// don't forget to trigger the requesttask.resume()

Page 46: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

NSURLSessionDelegate

Provide a delegate if you need more advanced control over:

• Download Progress

• Authentication Challenges

• Connection Failure

Page 47: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

NSURLSessionDelegate

Page 48: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Case Study: Requesting Images

Page 49: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Have you ever seen this?

NSURL *imageUrl = [NSURL URLWithString:@”http://i.imgur.com/kwpjYwQ.jpg”];

NSData *imageData = [NSData dataWithContentsOfURL:imageUrl];

UIImage *image = [UIImage imageWithData:imageData];

[imageView setImage:image];

Page 50: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache
Page 51: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

What is wrong here?

NSURL *imageUrl = [NSURL URLWithString:@”http://i.imgur.com/kwpjYwQ.jpg”];

NSData *imageData = [NSData dataWithContentsOfURL:imageUrl];

UIImage *image = [UIImage imageWithData:imageData];

[imageView setImage:image];

Page 52: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

These are blocking calls

! NSData *imageData = [NSData dataWithContentsOfURL:imageUrl];

! UIImage *image = [UIImage imageWithData:imageData];

Page 53: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache
Page 54: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Demo:Downloading Images

Page 55: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

• Images should probably be requested with download tasks

• Block-based callbacks can be unwieldy (especially in Objective-C)

• Use the delegate if you want to report download progress

Page 56: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Demo:Searching the iTunes Store

Page 57: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

HTTP

Page 58: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Status Code Cheat Sheet

1xx - Informational / Transient2xx - A-OK !3xx - It's over there "4xx - You Messed up ✋5xx - We Messed Up $

Page 59: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

HTTP Caching

Page 60: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

HTTP Caching Techniques

• If-Modified-Since

• If-None-Match

• Cache-Control

Page 61: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

If-Modified-Since

• Client requests a resource

• Server responds, includes a Date response header

• Client Caches the data, including the date

• Client sends request header If-Modified-Since

• Server compares, can return 304 (Not Modified) with no body

Page 62: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

If-None-Match

• Client requests a resource

• Server responds, includes a E-Tag header

• Client Caches the data, including the E-Tag

• Client sends request header If-None-Match

• Server compares, can return 304 (Not Modified) with no body

Page 63: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Cache-Control

• Server indicates when the resource expires

• Client caches the data until that time

• Client will immediately return local cache data if still fresh

Page 64: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

What does it look like on the client?

Page 65: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache
Page 66: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache
Page 67: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache
Page 68: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

What does it look like on the server?

Page 69: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

def show @band = Band.find(params[:id]) fresh_when(:etag => @band, :last_modified => @band, :public => true) expires_in 10.minutes, :public => trueend

Page 70: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Observations

• Server still executes a query to compute E-Tag and Modified Date

• No body is transfered for a matching E-Tag or Date

• Client doesn't even make request if Cache-Control is used and content is still fresh

Page 71: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Cache-Control sounds perfect

• Not everything is inherently cacheable

• Only helpful for a single client, after the initial request

Page 72: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache
Page 73: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Reverse-Proxy Cache to the Rescue

Page 74: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache
Page 75: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Pros / Cons of Cache-Control

• Client doesn't wait for a network request

• Server spends zero resources

• Clients May Render Stale Data

Page 76: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Pros / Cons of E-Tag & IMS

• Server skips rendering

• Miniscule Data Transfer

• Can appear instantaneous*

• Server still spending resources computing & comparing E-Tag & dates

Page 77: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Reason About Your Data

• List of US States

• User’s Profile

• Customer’s Order

• Activity Timeline

• Yesterday’s stats

Page 78: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Tradeoff betweenfresh data and user experience

Page 79: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Caching with NSURLSession

Page 80: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

• Uses NSURLCache out of the box

• Customize on the NSURLSessionConfiguration instance

• Use ephemeralSessionConfiguration to disable caching.

Page 81: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

NSURLCache Gotchas

Page 82: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

NSURLCache Gotchas

• will not cache on disk if max-age is less than 5 minutes

Page 83: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

NSURLCache Gotchas

• will not cache on disk if max-age is less than 5 minutes

• might not cache at all if Cache-Control isn't passed

Page 84: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

NSURLCache Gotchas

• will not cache on disk if max-age is less than 5 minutes

• might not cache at all if Cache-Control isn't passed

• might choose an arbitrarily large max-age if none provided *

Page 85: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

NSURLCache Gotchas

• will not cache on disk if max-age is less than 5 minutes

• might not cache at all if Cache-Control isn't passed

• might choose an arbitrarily large max-age if none provided *

• might not cache if size > 5% of available capacity

Page 86: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Tuning the built-in cache

let MB = 1024 * 1024 var cache = NSURLCache(memoryCapacity: 10 * MB, diskCapacity: 50 * MB, diskPath: nil)

sessionConfiguration.URLCache = cache

Page 87: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Default Cache Location

• ~/Library/Caches/com.acme.app/Cache.db

Page 88: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache
Page 89: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

What do I have to do?

Page 90: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Maybe nothing!• Server should return appropriate cache headers

• Tweak caching behavior in willCacheResponse delegate method

Page 91: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

The Content Flicker Problem

Page 92: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

The Content Flicker Problem

• Data is already cached and fresh with E-Tag / IMS info

• Client must validate content is still fresh and wait for a 304

• Response is fast, but not fast to avoid drawing empty screen

• ...flicker

Page 93: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Resolving the Content Flicker Problem

Page 94: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

1. Return cached data immediately (if we have it)

2. Proceed with Request

3. Update callback (again) with fresh data

Page 95: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

let url = NSURL(string: "http://cache-tester.herokuapp.com/contacts.json")let request = NSURLRequest(URL: url)

var task = session.dataTaskWithRequest(request)task.resume()

Page 96: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

let url = NSURL(string: "http://cache-tester.herokuapp.com/contacts.json")let request = NSURLRequest(URL: url)

if let cachedResponse = config.URLCache.cachedResponseForRequest(request) { // update UI processData(cachedResponse.data)}

var task = session.dataTaskWithRequest(request)task.resume()

Page 97: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

New in iOS 8: getCachedResponseForTask:

• Provides asynchronous cache fetch:let url = NSURL(string: "http://localhost:3000/contacts.json")let request = NSURLRequest(URL: url)

var task = session.dataTaskWithRequest(request)

config.URLCache.getCachedResponseForDataTask(task) { (let cachedResponse: NSCachedURLResponse?) in if cachedResponse != nil { self.processData(cachedResponse!.data) }

task.resume()}

Page 98: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Bonus RoundAPI Tips

Page 99: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Don't Expose your Internal Model

Page 100: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Version Your API

Page 101: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Send Device Info as Headers

Page 102: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Turn on Gzip Compression

Page 103: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Measure Response Times

Page 104: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Page Unbounded Data Sets

Page 105: Effective Networking - YOW! Conferences · NSURLConnection Invented for Safari ~2000 Made public in 2003 Poor separation of settings, config, cache

Thank [email protected]

@subdigital • @nsscreencastbenscheirman.com • nsscreencast.comspeakerdeck.com/subdigital/

ios8-networking