Let's Talk:
Efficient Communication
between PHP and Android

Matthew Turland

There (Will) Be Slides

Publications section of my web site at matthewturland.com

Publications section of http://matthewturland.com

I Work Here


Synacor Headquarters - Buffalo, NY

I Co/Wrote These

php|architect's Guide to Web Scraping with PHP
PHP Master: Write Cutting-Edge Code

Also Relevant

'PHP Web Services' by Lorna Jane Mitchell from O'Reilly Press

Lay of the Land

Windows Resource Monitor showing huge network activity spikes

Lafayette Traffic

Google Maps with points for accidents and cameras
Traffic camera feed

Free and Open Source (BSD License)

Related blog post


ElePHPant PHP logo Android logo


Borat with thumbs up


Drawing highlighting HTTP as a common protocol between browsers and servers


Roy Fielding

A Common Request

GET /foo HTTP/1.1
Accept: application/json;q=1, application/xml;q=0.5
Accept-Encoding: gzip, deflate

Android logo

A Common Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Encoding: gzip


ElePHPant PHP logo

Client Needs Internet Access

More on Permissions

Jackie Chan 'My Brain is Full of ****' meme with the caption, 'How could you post that without internet??'

Checking Network State

Client Needs an HTTP Client

Samuel L. Jackson playing Jules in Pulp Fiction with the caption, 'HTTP / DO YOU SPEAK IT'

A Simple Request

Keeping It Asynchronous

Application Not Responding error in an Android application

Accessing Local Services

An image from the Computer Reaction Face meme subgenre

Environment Detection

Server Supported Types

Keanu Reeves as Neo in The Matrix with the caption 'I Know Kung Fu'

Client Supported Types

The xkcd strip 'Labyrinth Puzzle'

Deriving Best Type

Grumpy cat meme

Content Negotiation

Mangalore leader holding Father Cornelius hostage in the negotiation scene of The Fifth Element

Content Compression

Portion of the 'Honey I Shrunk the Kids' movie poster

Server Compression Schemes

The xkcd strip 'File Transfer'

Client Compression Schemes

Steven Steagal in chef apparel with the caption 'Easy sauce? I put it on everything.'

Deriving Best
Compression Scheme

Captain Kirk from Star Trek with the caption, 'I'm sorry, I can't hear you over the sound of how awesome I am'

A Simple Comparison

By the Numbers

Scheme Size (b) Size (ratio) Runtime (ms)
None 10,337 1.000 0.000
bzip2 1,515 0.147 7.010
gzip 1,712 0.166 0.996
deflate 1,716 0.166 0.858

Back to the Client

Delorean from Back to the Future

Decoding the Response

Adam in the downtown scene of Honey I Blew Up the Kid

Batteries Not Included

Johnny Five from Short Circuit

Stream to String

Ghostbusters with the caption 'Don't cross the streams'

Parsing the Response

Disassembled car

Stream Parsing

Response Caching

Time-Based Caching

Tag-Based Caching

Pre-ICS Cache Reading

Pre-ICS Cache Writing

That's All, Folks