What happens when you enter a url into the address bar of a web browser and hit enter
- This is a common interview question
Stores no state, simple text documents transferred back and forth.
- GET - Retrieve information identified by the Request-URI
- GET /users => All users
- POST - Create a new resource identified by the Request-URI
- POST /users => Create a new user
- PUT - Update a specific resource identified by the Request-URI
- PUT /users/1 => update existing user with id of 1
- DELETE - Delete the resource identified by the Request-URI
- DELETE /users/1 => delete existing user with id of 1
All of the verb decisions are decided within your application. You can go against protocol in your application. ex:
get '/users' do
create_user
end
You shouldn't do this and should stick to following the protocol.
- Massive database mapping domain names to IP addresses.
- Translates domain names to the numerical IP addresses.
- First place it looks is in the cache of the local machine.
- If it doesn't find it there, it looks in the cache of the local network.
- Next if will check the ISP to if it has it cached.
- Finally it checks the DNS space
- In DNS it first checks Resolving Name Server
- Root Server
- .com
- .net
- TLD servers
- Top Level Domain Servers Every step of the journey what is found is cached.
- IPv4 uses 32-bit addresses or 2**32 (4,294,967,296)
- Human readable: 172.16.254.1
- Translates to: 10101100.00010000.11111110.00000001
- Reserved address (127.0.0.1)
- IPv6 uses 128-bit addresses or 2**128
- (340.282.366.920.938.463.463.374.607.431.768.211.456)
The server is listening for traffic on a specific port.
- Port 80 is commonly used for http
- Port 22 is commonly used for ssh
- To protect server against ssh attacks you can close port 22 and use ssh on a secondary port.
- Port 443 is commonly used for https Programs like Nginx and Apache watch the port waiting for the traffic to come in.
Nginx and Apache are referred to as web servers or HTTP servers.
Puma and Unicorn are referred to as application servers.