SlideShare a Scribd company logo
1 of 42
The Application Layer:
HTTP: Introduction
CS 352, Lecture 4.1
http://www.cs.rutgers.edu/~sn624/352
Srinivas Narayana
1
Review of concepts
• Layering and modularity; application layer
• 4-tuple (IPs, ports, IPd, portd), socket
• Client-server, peer to peer architectures
Application
Transport
Network
Host-to-Net
…
FTP HTTP SIP RTSP
TCP UDP
IP
802.11 X.25 ATM
HTTPS
The Web: Humble origins
Tim Berners-Lee: a way to
manage and access documents
at CERN research lab
Info containing links to other info,
accessible remotely, through a
standardized mechanism.
His boss is said to have written
on his proposal:
“vague, but exciting”
4
Web and HTTP: Some terms
• HTTP stands for “HyperText Transfer Protocol”
• A web page consists of many objects
• Object can be HTML file, JPEG image, video stream chunk, audio file,…
• Web page consists of base HTML-file which includes several referenced
objects.
• Each object is addressable by a uniform resource locator (URL)
• sometimes also referred to as uniform resource identifier (URI)
• Example URL:
www.cs.rutgers.edu/~sn624/index.html
host name path name
HTTP Protocol Overview
6
HTTP: hypertext transfer
protocol
• Client/server model
• Client: browser that requests,
receives, “displays” Web objects
• Server: Web server sends
objects in response to requests
• HTTP 1.0: RFC 1945
• HTTP 1.1: RFC 2068
PC running
Chrome
Web Server
e.g., Apache HTTP
server, nginx, etc.
Mac running
Safari
HTTP overview
Client server connection
Hostname IP address
Cs.Rutgers.edu 10.0.1.2
7
Host name
IP Address
DNS
HTTP messages
HTTP application
typically
associated with
port 80
8
HTTP messages: request message
• ASCII (human-readable format)
GET /352/syllabus.html HTTP/1.1
Host: www.cs.rutgers.edu
User-agent: Mozilla/4.0
Connection: close
Accept-language:en
(extra carriage return, line feed)
request line
(GET, POST,
HEAD commands)
Header lines
Carriage return,
line feed
indicates end
of message
9
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14
HTTP Request: General format
10
• GET
• Get the resource specified in the
requested URL. URL may refer to a
data-handling process
• POST
• Send entities (specified in the entity
body) to a data-handling process at the
requested URL
• HEAD
• Asks server to leave requested object
out of response, but send the rest of
the response
• PUT
• Update a resource at the requested
URL with the new entity specified in
the entity body
• DELETE
• Deletes file specified in the URL
• ... and other methods.
HTTP method types
Difference between POST and PUT
• POST: the URL of the request
identifies the resource that
processes the entity body
• PUT: the URL of the request
identifies the resource that is
contained in the entity body
https://tools.ietf.org/html/rfc2616
Difference between HEAD and GET
• GET: return the requested
resource in the entity body of
the response along with
response headers (we’ll see
these shortly)
• HEAD: return all the response
headers in the GET response,
but without the resource in
the entity body
https://tools.ietf.org/html/rfc2616
13
POST method:
• Web page often includes form
input
• Input is uploaded to server in
entity body
• Posted content not visible in
the URL
• Free form content (ex: images)
can be posted since entity body
interpreted as data bytes
GET method:
• Entity body is empty
• Input is uploaded in URL field of request
line
• Example:
• http://site.com/form?first=jane&last=austen
Uploading form input: GET and POST
Observing HTTP GET and POST
• A small demo
15
Unlike HTTP
request, No
method
name
HTTP Response: General format
16
HTTP message: response message
HTTP/1.1 200 OK
Connection: close
Date: Thu, 06 Aug 1998 12:00:15 GMT
Server: Apache/1.3.0 (Unix)
Last-Modified: Mon, 22 Jun 1998 …...
Content-Length: 6821
Content-Type: text/html
data data data data data ...
status line
(protocol
status code
status phrase)
response
header
lines
data, e.g., requested
HTML file in entity body
17
200 OK
• request succeeded, requested object later in this message
301 Moved Permanently
• requested object moved, new location specified later in this
message (Location:)
403 Forbidden
• Insufficient permissions to access the resource
404 Not Found
• requested document not found on this server
505 HTTP Version Not Supported
In first line in server->client response message.
A few sample codes:
HTTP response status codes
18
1. Telnet to your favorite Web server:
Opens TCP connection to port 80
(default HTTP server port).
Anything typed in sent
to port 80 at web.mit.edu
telnet web.mit.edu 80
2. Type in a GET HTTP request:
GET / HTTP/1.1
Host: web.mit.edu
By typing this in (hit carriage
return twice), you send
this minimal (but complete)
GET request to HTTP server
3. Look at response message sent by HTTP server!
Try sending a HTTP request yourself!
HTTP: Persistence,
Cookies, and Caching
CS 352, Lecture 4.2
http://www.cs.rutgers.edu/~sn624/352
Srinivas Narayana
20
21
Additional details about HTTP
• Persistent vs. Nonpersistent HTTP connections
• Cookies (User-server state)
• Web caches
Non/Persistent HTTP
23
Non-persistent HTTP
• At most one object is sent
over a TCP connection.
• HTTP/1.0 uses nonpersistent
HTTP
Persistent HTTP
• Multiple objects can be sent
over single TCP connection
between client and server.
• HTTP/1.1 uses persistent
connections in default mode
TCP is a kind of reliable communication service provided by the transport layer. It
requires the connection to be “set up” before data communication.
HTTP connections
24
Suppose user
visits a page
with text and 10
images.
1a. HTTP client initiates TCP
connection to HTTP server
2. HTTP client sends HTTP
request message
1b. HTTP server at host “accepts”
connection, notifying client
3. HTTP server receives request
message, replies with response
message containing requested
object
time
Non-persistent HTTP
25
5. HTTP client receives response
message containing html file,
displays html. Parsing html file,
finds 10 referenced jpeg objects
6. Steps 1-5 repeated for each of
10 jpeg objects
4. HTTP server closes TCP
connection.
time
Non-persistent HTTP (contd.)
26
Round Trip Time (RTT): time to send
a packet from client to server and
back.
• Sum of propagation, transmission,
and queueing delays along both
directions.
Response time:
• One RTT to initiate TCP connection
• One RTT for HTTP request and first
few bytes of HTTP response to
return
• File transmission time
total = 2RTT + file transmission time
time to
transmit
file
initiate TCP
connection
RTT
request
file
RTT
file
received
time time
Non-Persistent HTTP’s Response time
27
5. HTTP client receives response
message containing html file,
displays html. Parsing html file,
finds 10 referenced jpeg objects
The 10 objects can be requested over
the same TCP connection.
i.e., save an RTT trying to open a new
TCP connection per object.
4. HTTP server sends a response.
Server keeps the TCP
connection alive.
time
Persistent HTTP: jumping to steps 4/5
28
Non-persistent HTTP requires at least 2 RTTs per object.
• For each object: Open TCP connection; send HTTP request &
receive response
Persistent HTTP: since server leaves connection open after
sending response, subsequent HTTP messages between
same client/server sent over the open connection
Save one RTT per object relative to non-persistent HTTP
In both cases, browsers have a choice of opening multiple
parallel connections.
Persistent vs. Non-persistent
Remembering HTTP users
30
So far, HTTP is “stateless”
• The server maintains no memory about past client requests
But state, i.e., memory, about the user at the server is
very useful!
• authorization
• shopping carts
• recommendations
• In general, user session state
HTTP: User data on servers?
31
client server
http request msg + auth
http response +
Set-cookie: 1678
http request (no auth)
cookie: 1678
Personalized http
response
http request (no auth)
cookie: 1678
Personalized http
response
cookie-
specific
action
cookie-
specific
action
server
creates ID
1678 for user
Cookie file
Amazon: 1678
Cookie file
Amazon: 1678
Cookie file
Amazon: 1678
one week later:
Cookies: Keeping user memory
Netflix: 436
Netflix: 436
Netflix: 436
32
Four components:
1. cookie header line of HTTP response message
2. cookie header line in HTTP request message
3. cookie file kept on user endpoint, managed by user’s
browser
4. back-end database maps cookie to user data at Web
endpoint
Client and server collaboratively track and remember the user’s
state.
How cookies work
33
PSA: Cookies and Privacy
• The Internet would be unusable without cookies.
• However, cookies permit sites to learn a lot about
you, from your behaviors.
• E.g., which products, topics, images, etc. are you
most interested in?
• What demographic do you belong to? Where?
• What kinds of ads will you likely click on?
• Tracking networks correlate this info across sites
• You might reasonably be concerned about your
privacy when online.
• Disable and delete unnecessary cookies by default
• Use privacy-conscious browsers, websites, tools:
DuckDuckGo, Brave, AdBlock Plus.
Caching in HTTP
35
Web caches: Machines that remember web responses for a network
Why cache web responses?
• Reduce response time for client requests
• Reduce traffic on an institution’s access link
Caches can be implemented in the form of a proxy server
Web caches
36
Web caching using a proxy server
GET foo.html
Web Server
(also called
origin server in
this context)
Clients
Proxy
Server
GET foo.html
Store foo.html
on receiving
response
• You can configure a HTTP
proxy on your laptop’s network
settings.
• If you do, your browser sends
all HTTP requests to the proxy
(cache).
• Hit: cache returns object
• Miss:
• cache requests object from origin
server
• caches it locally
• and returns it to client
The Internet
37
• Conditional GET
guarantees cache content
is up-to-date while still
saves traffic and response
time whenever possible
• Date in the cache’s
request is the last time the
server provided in its
response header “last
modified”
cache server
HTTP request msg
If-modified-since:
<date>
HTTP response
HTTP/1.0
304 Not Modified
object
not
modified
HTTP request msg
If-modified-since:
<date>
HTTP response
HTTP/1.0 200 OK
<data>
object
modified
Web Caches: how does it look on HTTP?
38
A global network of web caches
• Provisioned by ISPs and network operators
• Or content providers, like Netflix, Google, etc.
Uses
• Reduce bandwidth requirements on content provider
• Reduce $$ to maintain origin servers
• Reduce traffic on a network’s Internet connection, e.g.,
Rutgers
• Improve response time to user for a service
Content Distribution Networks (CDN)
Without CDN
• Huge bandwidth requirements for Rutgers
• Large propagation delays to reach users
• So, distribute content to geographically distributed cache servers.
• Often, use DNS to redirect request to users to copies of content
39
128.6.4.2
DOMAIN NAME IP ADDRESS
www.yahoo.com 98.138.253.109
cs.rutgers.edu 128.6.4.2
www.google.com 74.125.225.243
www.princeton.edu 128.112.132.86
Cluster with Rutgers CS
origin servers
• Origin server
• Server that holds the authoritative copy of the content
• CDN server
• A replica server owned by the CDN provider
• CDN name server
• A DNS like name server used for redirection
• Client
CDN terms
128.6.4.2
DOMAIN NAME IP ADDRESS
www.yahoo.com 98.138.253.109
cs.rutgers.edu 124.8.9.8 (NS of CDN)
www.google.com 74.125.225.243
www.princeton.edu 128.112.132.86
DOMAIN NAME IP ADDRESS
www.yahoo.com 12.1.2.3
www.yahoo.com 12.1.2.4
www.yahoo.com 12.1.2.5
www.yahoo.com 12.1.2.6
CDN Name Server (124.8.9.8)
12.1.2.3
12.1.2.4
12.1.2.5
12.1.2.6
Origin server
Client
CDN servers
With CDN
Custom
logic to
map ONE
domain
name to
one of
many IP
addresses!
Implement DNS
delegation to the
CDN name server.
“layer of indirection”
Most requests go to CDN servers (caches).
Only the remainder go to the origin server.
42
Themes from HTTP
• Request/response nature of the protocol
• Special HTTP headers to customize actions of the protocol
• ASCII-based message structures
• Improve performance using caching
• Scale using a layer of indirection
• Simple, highly-customizable protocol, permitting efficient
implementations and flexible functionality.
• The basis of why we enjoy the web today.

More Related Content

Similar to HTTP: Introduction to Protocol, Persistence, Cookies and Caching

Web-01-HTTP.pptx
Web-01-HTTP.pptxWeb-01-HTTP.pptx
Web-01-HTTP.pptxAliZaib71
 
HyperText Transfer Protocol (HTTP)
HyperText Transfer Protocol (HTTP)HyperText Transfer Protocol (HTTP)
HyperText Transfer Protocol (HTTP)Gurjot Singh
 
Hypertexttransferprotocolhttp 131012171813-phpapp02
Hypertexttransferprotocolhttp 131012171813-phpapp02Hypertexttransferprotocolhttp 131012171813-phpapp02
Hypertexttransferprotocolhttp 131012171813-phpapp02Nidhitransport
 
4-Lect_4-2.pptx4-Lect_4-2.pptx4-Lect_4-2.pptx
4-Lect_4-2.pptx4-Lect_4-2.pptx4-Lect_4-2.pptx4-Lect_4-2.pptx4-Lect_4-2.pptx4-Lect_4-2.pptx
4-Lect_4-2.pptx4-Lect_4-2.pptx4-Lect_4-2.pptxZahouAmel1
 
CNIT 129S - Ch 3: Web Application Technologies
CNIT 129S - Ch 3: Web Application TechnologiesCNIT 129S - Ch 3: Web Application Technologies
CNIT 129S - Ch 3: Web Application TechnologiesSam Bowne
 
Httpbasics 1207412539273264-9-converted
Httpbasics 1207412539273264-9-convertedHttpbasics 1207412539273264-9-converted
Httpbasics 1207412539273264-9-convertedcomputerorganization
 
Class 1 - World Wide Web Introduction
Class 1 - World Wide Web IntroductionClass 1 - World Wide Web Introduction
Class 1 - World Wide Web IntroductionAhmed Swilam
 
Web Services 2009
Web Services 2009Web Services 2009
Web Services 2009Cathie101
 
Web Services 2009
Web Services 2009Web Services 2009
Web Services 2009Cathie101
 
CNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application TechnologiesCNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application TechnologiesSam Bowne
 

Similar to HTTP: Introduction to Protocol, Persistence, Cookies and Caching (20)

Web technology Unit I Part C
Web technology Unit I  Part CWeb technology Unit I  Part C
Web technology Unit I Part C
 
Browser
BrowserBrowser
Browser
 
Http
HttpHttp
Http
 
Http
HttpHttp
Http
 
Http_Protocol.pptx
Http_Protocol.pptxHttp_Protocol.pptx
Http_Protocol.pptx
 
Web-01-HTTP.pptx
Web-01-HTTP.pptxWeb-01-HTTP.pptx
Web-01-HTTP.pptx
 
HyperText Transfer Protocol (HTTP)
HyperText Transfer Protocol (HTTP)HyperText Transfer Protocol (HTTP)
HyperText Transfer Protocol (HTTP)
 
Hypertexttransferprotocolhttp 131012171813-phpapp02
Hypertexttransferprotocolhttp 131012171813-phpapp02Hypertexttransferprotocolhttp 131012171813-phpapp02
Hypertexttransferprotocolhttp 131012171813-phpapp02
 
4-Lect_4-2.pptx4-Lect_4-2.pptx4-Lect_4-2.pptx
4-Lect_4-2.pptx4-Lect_4-2.pptx4-Lect_4-2.pptx4-Lect_4-2.pptx4-Lect_4-2.pptx4-Lect_4-2.pptx
4-Lect_4-2.pptx4-Lect_4-2.pptx4-Lect_4-2.pptx
 
CNIT 129S - Ch 3: Web Application Technologies
CNIT 129S - Ch 3: Web Application TechnologiesCNIT 129S - Ch 3: Web Application Technologies
CNIT 129S - Ch 3: Web Application Technologies
 
IP UNIT 1.pptx
IP UNIT 1.pptxIP UNIT 1.pptx
IP UNIT 1.pptx
 
Lecture 6- http
Lecture  6- httpLecture  6- http
Lecture 6- http
 
Httpbasics 1207412539273264-9-converted
Httpbasics 1207412539273264-9-convertedHttpbasics 1207412539273264-9-converted
Httpbasics 1207412539273264-9-converted
 
Class 1 - World Wide Web Introduction
Class 1 - World Wide Web IntroductionClass 1 - World Wide Web Introduction
Class 1 - World Wide Web Introduction
 
Web Services 2009
Web Services 2009Web Services 2009
Web Services 2009
 
Web Services 2009
Web Services 2009Web Services 2009
Web Services 2009
 
http presentation 1.pptx
http presentation 1.pptxhttp presentation 1.pptx
http presentation 1.pptx
 
computer networking
computer networkingcomputer networking
computer networking
 
Appl layer
Appl layerAppl layer
Appl layer
 
CNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application TechnologiesCNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application Technologies
 

More from ssuseraf60311

String-Matching Algorithms Advance algorithm
String-Matching  Algorithms Advance algorithmString-Matching  Algorithms Advance algorithm
String-Matching Algorithms Advance algorithmssuseraf60311
 
Graph coloring with back tracking aoa.ppt
Graph coloring with back tracking aoa.pptGraph coloring with back tracking aoa.ppt
Graph coloring with back tracking aoa.pptssuseraf60311
 
Working of web browser.pptx
Working of web browser.pptxWorking of web browser.pptx
Working of web browser.pptxssuseraf60311
 

More from ssuseraf60311 (7)

String-Matching Algorithms Advance algorithm
String-Matching  Algorithms Advance algorithmString-Matching  Algorithms Advance algorithm
String-Matching Algorithms Advance algorithm
 
Graph coloring with back tracking aoa.ppt
Graph coloring with back tracking aoa.pptGraph coloring with back tracking aoa.ppt
Graph coloring with back tracking aoa.ppt
 
3526192.ppt
3526192.ppt3526192.ppt
3526192.ppt
 
8259731.ppt
8259731.ppt8259731.ppt
8259731.ppt
 
fit100-16-dom.ppt
fit100-16-dom.pptfit100-16-dom.ppt
fit100-16-dom.ppt
 
6065165.ppt
6065165.ppt6065165.ppt
6065165.ppt
 
Working of web browser.pptx
Working of web browser.pptxWorking of web browser.pptx
Working of web browser.pptx
 

Recently uploaded

Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 

Recently uploaded (20)

Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 

HTTP: Introduction to Protocol, Persistence, Cookies and Caching

  • 1. The Application Layer: HTTP: Introduction CS 352, Lecture 4.1 http://www.cs.rutgers.edu/~sn624/352 Srinivas Narayana 1
  • 2. Review of concepts • Layering and modularity; application layer • 4-tuple (IPs, ports, IPd, portd), socket • Client-server, peer to peer architectures Application Transport Network Host-to-Net … FTP HTTP SIP RTSP TCP UDP IP 802.11 X.25 ATM HTTPS
  • 3. The Web: Humble origins Tim Berners-Lee: a way to manage and access documents at CERN research lab Info containing links to other info, accessible remotely, through a standardized mechanism. His boss is said to have written on his proposal: “vague, but exciting”
  • 4. 4 Web and HTTP: Some terms • HTTP stands for “HyperText Transfer Protocol” • A web page consists of many objects • Object can be HTML file, JPEG image, video stream chunk, audio file,… • Web page consists of base HTML-file which includes several referenced objects. • Each object is addressable by a uniform resource locator (URL) • sometimes also referred to as uniform resource identifier (URI) • Example URL: www.cs.rutgers.edu/~sn624/index.html host name path name
  • 6. 6 HTTP: hypertext transfer protocol • Client/server model • Client: browser that requests, receives, “displays” Web objects • Server: Web server sends objects in response to requests • HTTP 1.0: RFC 1945 • HTTP 1.1: RFC 2068 PC running Chrome Web Server e.g., Apache HTTP server, nginx, etc. Mac running Safari HTTP overview
  • 7. Client server connection Hostname IP address Cs.Rutgers.edu 10.0.1.2 7 Host name IP Address DNS HTTP messages HTTP application typically associated with port 80
  • 8. 8 HTTP messages: request message • ASCII (human-readable format) GET /352/syllabus.html HTTP/1.1 Host: www.cs.rutgers.edu User-agent: Mozilla/4.0 Connection: close Accept-language:en (extra carriage return, line feed) request line (GET, POST, HEAD commands) Header lines Carriage return, line feed indicates end of message
  • 10. 10 • GET • Get the resource specified in the requested URL. URL may refer to a data-handling process • POST • Send entities (specified in the entity body) to a data-handling process at the requested URL • HEAD • Asks server to leave requested object out of response, but send the rest of the response • PUT • Update a resource at the requested URL with the new entity specified in the entity body • DELETE • Deletes file specified in the URL • ... and other methods. HTTP method types
  • 11. Difference between POST and PUT • POST: the URL of the request identifies the resource that processes the entity body • PUT: the URL of the request identifies the resource that is contained in the entity body https://tools.ietf.org/html/rfc2616
  • 12. Difference between HEAD and GET • GET: return the requested resource in the entity body of the response along with response headers (we’ll see these shortly) • HEAD: return all the response headers in the GET response, but without the resource in the entity body https://tools.ietf.org/html/rfc2616
  • 13. 13 POST method: • Web page often includes form input • Input is uploaded to server in entity body • Posted content not visible in the URL • Free form content (ex: images) can be posted since entity body interpreted as data bytes GET method: • Entity body is empty • Input is uploaded in URL field of request line • Example: • http://site.com/form?first=jane&last=austen Uploading form input: GET and POST
  • 14. Observing HTTP GET and POST • A small demo
  • 16. 16 HTTP message: response message HTTP/1.1 200 OK Connection: close Date: Thu, 06 Aug 1998 12:00:15 GMT Server: Apache/1.3.0 (Unix) Last-Modified: Mon, 22 Jun 1998 …... Content-Length: 6821 Content-Type: text/html data data data data data ... status line (protocol status code status phrase) response header lines data, e.g., requested HTML file in entity body
  • 17. 17 200 OK • request succeeded, requested object later in this message 301 Moved Permanently • requested object moved, new location specified later in this message (Location:) 403 Forbidden • Insufficient permissions to access the resource 404 Not Found • requested document not found on this server 505 HTTP Version Not Supported In first line in server->client response message. A few sample codes: HTTP response status codes
  • 18. 18 1. Telnet to your favorite Web server: Opens TCP connection to port 80 (default HTTP server port). Anything typed in sent to port 80 at web.mit.edu telnet web.mit.edu 80 2. Type in a GET HTTP request: GET / HTTP/1.1 Host: web.mit.edu By typing this in (hit carriage return twice), you send this minimal (but complete) GET request to HTTP server 3. Look at response message sent by HTTP server! Try sending a HTTP request yourself!
  • 19.
  • 20. HTTP: Persistence, Cookies, and Caching CS 352, Lecture 4.2 http://www.cs.rutgers.edu/~sn624/352 Srinivas Narayana 20
  • 21. 21 Additional details about HTTP • Persistent vs. Nonpersistent HTTP connections • Cookies (User-server state) • Web caches
  • 23. 23 Non-persistent HTTP • At most one object is sent over a TCP connection. • HTTP/1.0 uses nonpersistent HTTP Persistent HTTP • Multiple objects can be sent over single TCP connection between client and server. • HTTP/1.1 uses persistent connections in default mode TCP is a kind of reliable communication service provided by the transport layer. It requires the connection to be “set up” before data communication. HTTP connections
  • 24. 24 Suppose user visits a page with text and 10 images. 1a. HTTP client initiates TCP connection to HTTP server 2. HTTP client sends HTTP request message 1b. HTTP server at host “accepts” connection, notifying client 3. HTTP server receives request message, replies with response message containing requested object time Non-persistent HTTP
  • 25. 25 5. HTTP client receives response message containing html file, displays html. Parsing html file, finds 10 referenced jpeg objects 6. Steps 1-5 repeated for each of 10 jpeg objects 4. HTTP server closes TCP connection. time Non-persistent HTTP (contd.)
  • 26. 26 Round Trip Time (RTT): time to send a packet from client to server and back. • Sum of propagation, transmission, and queueing delays along both directions. Response time: • One RTT to initiate TCP connection • One RTT for HTTP request and first few bytes of HTTP response to return • File transmission time total = 2RTT + file transmission time time to transmit file initiate TCP connection RTT request file RTT file received time time Non-Persistent HTTP’s Response time
  • 27. 27 5. HTTP client receives response message containing html file, displays html. Parsing html file, finds 10 referenced jpeg objects The 10 objects can be requested over the same TCP connection. i.e., save an RTT trying to open a new TCP connection per object. 4. HTTP server sends a response. Server keeps the TCP connection alive. time Persistent HTTP: jumping to steps 4/5
  • 28. 28 Non-persistent HTTP requires at least 2 RTTs per object. • For each object: Open TCP connection; send HTTP request & receive response Persistent HTTP: since server leaves connection open after sending response, subsequent HTTP messages between same client/server sent over the open connection Save one RTT per object relative to non-persistent HTTP In both cases, browsers have a choice of opening multiple parallel connections. Persistent vs. Non-persistent
  • 30. 30 So far, HTTP is “stateless” • The server maintains no memory about past client requests But state, i.e., memory, about the user at the server is very useful! • authorization • shopping carts • recommendations • In general, user session state HTTP: User data on servers?
  • 31. 31 client server http request msg + auth http response + Set-cookie: 1678 http request (no auth) cookie: 1678 Personalized http response http request (no auth) cookie: 1678 Personalized http response cookie- specific action cookie- specific action server creates ID 1678 for user Cookie file Amazon: 1678 Cookie file Amazon: 1678 Cookie file Amazon: 1678 one week later: Cookies: Keeping user memory Netflix: 436 Netflix: 436 Netflix: 436
  • 32. 32 Four components: 1. cookie header line of HTTP response message 2. cookie header line in HTTP request message 3. cookie file kept on user endpoint, managed by user’s browser 4. back-end database maps cookie to user data at Web endpoint Client and server collaboratively track and remember the user’s state. How cookies work
  • 33. 33 PSA: Cookies and Privacy • The Internet would be unusable without cookies. • However, cookies permit sites to learn a lot about you, from your behaviors. • E.g., which products, topics, images, etc. are you most interested in? • What demographic do you belong to? Where? • What kinds of ads will you likely click on? • Tracking networks correlate this info across sites • You might reasonably be concerned about your privacy when online. • Disable and delete unnecessary cookies by default • Use privacy-conscious browsers, websites, tools: DuckDuckGo, Brave, AdBlock Plus.
  • 35. 35 Web caches: Machines that remember web responses for a network Why cache web responses? • Reduce response time for client requests • Reduce traffic on an institution’s access link Caches can be implemented in the form of a proxy server Web caches
  • 36. 36 Web caching using a proxy server GET foo.html Web Server (also called origin server in this context) Clients Proxy Server GET foo.html Store foo.html on receiving response • You can configure a HTTP proxy on your laptop’s network settings. • If you do, your browser sends all HTTP requests to the proxy (cache). • Hit: cache returns object • Miss: • cache requests object from origin server • caches it locally • and returns it to client The Internet
  • 37. 37 • Conditional GET guarantees cache content is up-to-date while still saves traffic and response time whenever possible • Date in the cache’s request is the last time the server provided in its response header “last modified” cache server HTTP request msg If-modified-since: <date> HTTP response HTTP/1.0 304 Not Modified object not modified HTTP request msg If-modified-since: <date> HTTP response HTTP/1.0 200 OK <data> object modified Web Caches: how does it look on HTTP?
  • 38. 38 A global network of web caches • Provisioned by ISPs and network operators • Or content providers, like Netflix, Google, etc. Uses • Reduce bandwidth requirements on content provider • Reduce $$ to maintain origin servers • Reduce traffic on a network’s Internet connection, e.g., Rutgers • Improve response time to user for a service Content Distribution Networks (CDN)
  • 39. Without CDN • Huge bandwidth requirements for Rutgers • Large propagation delays to reach users • So, distribute content to geographically distributed cache servers. • Often, use DNS to redirect request to users to copies of content 39 128.6.4.2 DOMAIN NAME IP ADDRESS www.yahoo.com 98.138.253.109 cs.rutgers.edu 128.6.4.2 www.google.com 74.125.225.243 www.princeton.edu 128.112.132.86 Cluster with Rutgers CS origin servers
  • 40. • Origin server • Server that holds the authoritative copy of the content • CDN server • A replica server owned by the CDN provider • CDN name server • A DNS like name server used for redirection • Client CDN terms
  • 41. 128.6.4.2 DOMAIN NAME IP ADDRESS www.yahoo.com 98.138.253.109 cs.rutgers.edu 124.8.9.8 (NS of CDN) www.google.com 74.125.225.243 www.princeton.edu 128.112.132.86 DOMAIN NAME IP ADDRESS www.yahoo.com 12.1.2.3 www.yahoo.com 12.1.2.4 www.yahoo.com 12.1.2.5 www.yahoo.com 12.1.2.6 CDN Name Server (124.8.9.8) 12.1.2.3 12.1.2.4 12.1.2.5 12.1.2.6 Origin server Client CDN servers With CDN Custom logic to map ONE domain name to one of many IP addresses! Implement DNS delegation to the CDN name server. “layer of indirection” Most requests go to CDN servers (caches). Only the remainder go to the origin server.
  • 42. 42 Themes from HTTP • Request/response nature of the protocol • Special HTTP headers to customize actions of the protocol • ASCII-based message structures • Improve performance using caching • Scale using a layer of indirection • Simple, highly-customizable protocol, permitting efficient implementations and flexible functionality. • The basis of why we enjoy the web today.