Web Basics
URL - Uniform Resource Locator
http://www.google.com/
protocol + host + path
Query Parameters (GET parameters) http://example.com/foo?p=100&q=meat
Fragment Used to reference a part of the page http://example.com/foo#fragment
Port
By default, it equals 80 http://example.com:80/toys?p=foo#blah
HTTP Request
http://example.com/foo GET /foo HTTP/1.1 //This is the request line Host: www.example.com // Followed by headers User-Agent: chrome
HTTP Response
HTTP/1.1 200 OK // Status line Date: xxx xxx xxx Server: Apache xxx Content-Type: text/html Content-Length: 1539
404 Not Found 500 Server Error
Servers
The purpose of the server is to response to HTTP requests
There are two types of content
- Static - images, files etc
- Dynamic - made on the fly by web applications
HTTPS
API
JSON Escaping
Caching
if request is in cache:
return cache[request] // cache hit
else
r = db_read() // cache miss
cache[request] = r
return r
Stateless
- stateless is the key to scaling
- there's no state between requests
- apps are now interchangable
- apps can be scaled independent of cache and db
- we can store state in: cookies, DB, memcached
Why do we separate our services?
- So they can be scaled independently
- To increase fault tolerance
- So they can be updated independently