¿Por qué estoy aquí? • Been nerding out on internet protocols (last week: IETF 95). • Think a better understanding of the network layer is really important.
More hosts === more complexity e.test/app.js index.html e.test/app.css "My App" g.test/analytics.js f.test/bootstrap.css z.test/font.woff z.test/foo.svg HTTP
Are we building distributed systems? "A distributed system consists of a collection of distinct processes which are spatially separated, and which communicate with one another by exchanging messages." —Leslie Lamport, 1978 See also: http://dl.acm.org/citation.cfm?id=2482856
It's not fast enough Source Destination Great Circle Distance Round Trip Time in Fiber SFO London 5,375 miles 84 ms SFO Cape Town 10,124 miles 158 ms SFO Montevideo 6,554 miles 102 ms 1 ms at speed of light = Slightly less than width of Uruguay
Origin Server Moving it closer with CDNs Browser CDN Edge HTTP HTTP Short distance Long Distance HTTP requests get routed to a nearby location using the CDN network.
Use the headers • Set headers on responses control to caching: • Cache-Control: max-age=10, public • The bigger the max-age is, the longer it is cached. • Always verify settings (check response headers in Chrome web inspector or cURL) Great resource: http://www.mobify.com/blog/beginners-guide-to-http-cache-headers/
File asset revisioning • The filename has an MD5 hash of the contents: app-d2ae34123.js • Cache-Control: max-age=31536000, public • Use a grunt and gulp plugin— someone has already done this (i.e. https://github.com/cbas/ grunt-rev)
The OSI Model explained using a chivito Physical (ethernet/pan) Data Link (ethernet/rodajas de tomate) Network (IP/panceta) Transport (TCP/jamón cocido) Session (mozzarella) Presentation (JPG/mayonesa) Application (HTTP/Currasco) Lower Layers Upper Layers