Tue Jan 07 - Written by: Samridha
Web Development Basics
An introduction to web development fundamentals, covering HTTP/HTTPS protocols, REST/GraphQL APIs, web architecture, and cloud-hosted applications.
Web Development Basics
HTTP/HTTPS Protocol
- Hyper Text Transfer Protocol (HTTP) and HTTP Secure (HTTPS) are protocols used for communication between clients and servers on the web.
- HTTPS adds an extra layer of security by encrypting communication using SSL (Secure Socket Layer) or TLS (Transport Layer Security).
Request and Response Structure:
- Request:
- Contains method, URL, headers, and an optional body.
- Response:
- Includes status code, headers, and an optional body.
Common HTTP Methods:
- GET: Fetch data from the server.
- POST: Send data to the server to create a resource.
- PUT: Update an existing resource on the server.
- DELETE: Remove a resource from the server.
Status Codes:
-
2xx: Success
- Example:
200 OK
,201 Created
,204 No Content
.
- Example:
-
3xx: Redirection
- Example:
301 Moved Permanently
,302 Found
,304 Not Modified
.
- Example:
-
4xx: Client Error
- Example:
400 Bad Request
,401 Unauthorized
,403 Forbidden
,404 Not Found
,429 Too Many Requests
.
- Example:
-
5xx: Server Error
- Example:
500 Internal Server Error
,502 Bad Gateway
,503 Service Unavailable
,504 Gateway Timeout
.
HTTP Status Codes
Code Message Description 200 OK Request was successful and response contains requested data. 201 Created New data was created after a POST request. 204 No Content Request was successful, but no content to return (e.g., after a DELETE request). 301 Moved Permanently Requested resource has been permanently moved to a different URL. 302 Found Requested resource has been temporarily moved to a different URL. 304 Not Modified Resource has not been modified since the last request. 400 Bad Request The server could not understand the request due to invalid syntax. 401 Unauthorized Authentication is required but was not provided or is invalid. 403 Forbidden Client understands the request but refuses to authorize it. 404 Not Found The requested resource could not be found on the server. 405 Method Not Allowed The request method is not supported for the requested resource. 429 Too Many Requests Client has sent too many requests in a short time (rate limiting). 500 Internal Server Error The server encountered an unexpected condition. 502 Bad Gateway The server received an invalid response from an upstream server. 503 Service Unavailable The server is temporarily unable to handle requests (e.g., maintenance). 504 Gateway Timeout The server did not receive a timely response from an upstream server. - Example:
REST and GraphQL APIs
- REST (Representational State Transfer):
- A design standard for web APIs that uses HTTP methods like GET, POST, PUT, DELETE.
- Resources are represented as URLs (e.g.,
/users
). - Responses are typically in JSON format.
- GraphQL:
- A flexible API query language that allows clients to request specific data in a single query.
- Ideal for modern applications with complex data requirements.
Web Architecture
Client-Server Model:
- Client: Sends requests and displays responses.
- Server: Processes requests and sends back responses.
Single-Page Applications (SPAs):
- Load a single HTML file and update content dynamically without reloading the page.
- Examples: Gmail, Trello.
- Advantages:
- Reduced server load after the initial page load.
- Fast and responsive user experience.
Microservices:
- Applications are divided into small, independent services that perform specific functionalities and communicate via APIs.
- Advantages:
- Scalability: Services can scale independently.
- Fault Isolation: Issues in one service do not affect the others.
Cloud-Hosted Applications:
- Applications are deployed on cloud platforms like AWS, Azure, or Google Cloud.
- Advantages:
- Scalability: Easily scale resources based on demand.
- Monitoring: Built-in tools for performance monitoring.
- High Availability: Redundancy and failover capabilities.