HTTP and Server Side Programming
HTTP and Server Side Programming
HTTP and Server Side Programming
Topics
HTTP
HTTP/1.x
HTTP/2
HTTP/3
However, you can create sessions using HTTP Cookies which allows sharing
the same context, or the same state between requests
HTTP Request/Response Flow
When a client wants to communicate with a server it performs the following
steps
Step-1: Open a TCP Connection
The TCP connection is used to send a request(s) and receive a response
The client may open a
new connection,
reuse an existing connection, or
open multiple TCP connections to the servers
HTTP Request/Response Flow
Step-2: Send an HTTP Message
GET / HTTP/1.1
Host: developer.mozilla.org
Accept-Language: fr
HTTP Request/Response Flow
Step-3: Read the HTTP/1.1 200 OK
Response sent by Date: Sat, 09 Oct 2010 14:28:02 GMT
Server: Apache
the Server
Last-Modified: Tue, 01 Dec 2009 20:18:22 GMT
ETag: "51142bc1-7449-479b075b2891b"
Accept-Ranges: bytes
Content-Length: 29769
Content-Type: text/html
HTTP/0.9
HTTP/1.0
HTTP/1.1
HTTP/2
HTTP/3
HTTP/0.9 – The one-line protocol
Requests consisted of a single line
GET /mypage.html
<html>
</html>
Characteristics of HTTP/0.9
Client request is a single ASCII character string
With the help of the new HTTP headers, the ability to transmit other
documents than plain HTML files has been added
The connection between server and client is closed after every request
HTTP/1.0 Example
Request line with HTTP
1
version number, followed by
request headers
Keepalive Connections
Byte-range Requests
The addition of the Host header allowed to host different domains at the
same IP address (allowing server colocation)
HTTP/1.1: Example
1 Request for HTML file, with encoding metadata
HTTP/1.1: Example
2 Chunked response for original HTML request
HTTP/1.1: Example
3 Number of octets in the chunk expressed as an
ASCII hexadecimal number
6
Inform server that the
connection will not be reused
HTTP/1.1: Example
7 Icon response, followed by connection close
Question
What is the name of the header part that is added on HTTP/1.1 version to
improve the limitation of HTTP/1.0 (requiring a new TCP connection for each
request)
Question
What do you think are the limitations of the HTTP/1.X protocol ?
Limitations of HTTP/1.x
Clients need to use multiple connections to achieve concurrency and
reduce latency
Does not allow effective resource prioritization, resulting in poor use of the
underlying TCP connection
SPDY
SPDY was an experimental protocol, developed at Google
Its primary goal was to try to reduce the load latency of web pages by
addressing some of the well-known performance limitations of HTTP/1.1
SPDY
The specific project goals were the following
As a result SPDY was supported in Chrome, Firefox, and Opera, and a rapidly
growing number of sites, both large (e.g., Google, Twitter, Facebook) and small
Single digit %
perf improvement
after
5 Mbps
Linear
improvement in
page load time!
Latency vs Bandwidth impact on Page Load Time
Decreasing latency has more impact than increasing bandwidth
For Example
Decreasing RTTs from 150 ms to 100 ms have a larger effect on the speed
of the internet than increasing a user’s bandwidth from 3.9 Mbps to 10
Mbps or even 1 Gbps
HTTP/2:Streams, Messages, and Frames
The introduction of the new binary framing mechanism changes how the
data is exchanged between the client and server
Stream
Message
Multiple Stream
HTTP/1.X vs HTTP/2 TCP Connection
Browsers Supporting HTTP/2
CanIUse
Connection migration
HTTP/3: HTTP over QUIC
Instead of using TCP as the transport layer for the session, it uses QUIC
QUIC streams are delivered independently such that in most cases packet loss
affecting one stream doesn't affect others.
QUIC also combines the typical 3-way TCP handshake with TLS 1.3's
handshake
CanIUse
HTTP Messages
HTTP messages, as defined in HTTP/1.1 and earlier, are human-readable
Even if only part of the original HTTP message is sent in HTTP/2, the
semantics of each message is unchanged and the client reconstitutes the
original HTTP/1.1 request
HTTP | MDN
https://www.rfc-editor.org/rfc/rfc9114.html
https://www.rfc-editor.org/rfc/rfc9000.html
Introduction to
Server Side Programming
Topics
Server-Side/Backend Programming
Static/Dynamic Websites
HTML pages are normally created by inserting data from a database into
placeholders in HTML templates
Can return different data for a URL based on information provided by the user
or stored preferences and can perform other operations as part of returning a
response
Dynamic Sites
What can you do on the server-side?
Efficient Storage and Delivery of Information
restrict access to authorized users and serve only the information that a
user is permitted to see
What can you do on the server-side?
Store Session/State Information
A website may collect a lot of data about users: what they search for, what
they buy, what they recommend, how long they stay on each page