Introduction
Summary
keywords
TODO
HW performance calculation on installing web cache
Exercise*
Next time HOL blocking
Recap
What kind of Application need which transport protocol?
TCP & UDP have no encryptions, throughput guarantee, timing,,
Web and HTTP
HTTP uses TCP TCP is closed after a certain amount of time, or certain amount of transmissions HTTP is stateless. headers do not store any stateful meanings.
Non-persistent TCP no longer used. High RTT One single connection on one transmssion
request and response
all human readable. Written in ASCII codes)
HTTP request message
composed of
- request line (method, url, version)
- header lines (header values)
- body (data)
in the request message,
- GET, POST, HEAD, PUT request types
- lines are broken down by
\r\n
For normal GET request, there's no body
GET
- send data to server by URL query (after question mark).
POST
- form input
HEAD
- request headers only.
- only used when checking server up status.
- will only send essential info
PUT
- upload a file; alternative for FTP.
- completely replaces file that exist at specified URL
Response message
composed of
- status line (HTTP/1.1 200 OK)
- header lines
- body
in the header
- Date, Server, Last-Modified,
- Etag,
- Accept-Ranges,
- (Content-Length, Content-Type..)
- and more..
Etag is used for caching page purposes. version controlling for page. ex . ( Etag : "abb-43kfnnldocmmdkvndls")
#todo : what is Accept-Ranges
Response status codes
code | name | description |
---|---|---|
200 | OK | success |
301 | Moved Permanently | request object moved, new location specified |
400 | Bad request | not understood by server |
404 | Not found | not found |
505 | HTTP Version Not supported | - |
and more..
Cookies
client-side tool to make WEB stateful.
- in HTTP, all request are independent of each other
- browser stores the cookie
- widely used in server identifying a client browser&machine
- Authorization, shopping carts, recommendations, user session state(e-mail..)
- when written in browser, it transcends time and can be used in the long apart future and show the seamless cookie-specific action.
four components of data storages
- cookie header line ( of response message)
- cookie header in next HTTP request message)
- cookie file kept on user's host, managed by user's
- back-end database at web site
#todo : check the python example on the slides.
import requests
response = requests.get("https://www.google.com")
if response.status_code == 200:
cookies = response.cookies
for cookie in cookies:
print(f"Cookie Name: {cookie.name}")
print(f"Cookie value: {cookie.value}")
else :
print("HTTP Error:",response.status_code,response.reason)
Cookie Name: 1P_JAR
Cookie value: 2023-09-14-04
Cookie Name: AEC
Cookie value: Ad49MVFXS3NX5m3l8PO4X5FUaFZvQI8b1Czl9-Ym1cAxZn7fTXSC5fXdAw
Cookie Name: NID
Cookie value: 511=m0D8Dti7MEGMgrBAZI_1a3ZfZ8xr9ydTVeHn60MicQtJztyPIo5Qj7U73zEnhAm8i1KeRJfAjsANOwpxvqaKfemnBYIWKnfl_OZOjFbDw6rMPjH_aEG9PFVAp20YMu8ZOpIaj7b7NBSauxhKPq3-ceyC3o-pyKj-X-5_T1G0ou4
- Cookie has trade-offs on privacy
- it is a info a lot about you.
- How to keep state? (other than cookies?)*
- cookies inside the HTTP message
- protocol endpoint ?
- #todo what is protocol endpoint
Web Caches
Intermediate servers that saves a server and sending pages instead of the origin server
- satisfy client request without involving origin server
- Act as a client against origin server, act as a server for end-users
- server tells cache about whether the object can be cached or not
Cache-Control: max-age=<seconds>
advantage
- makes less load on the origin server
- reduce response time
- reduces traffic on the backbone network
following is a small server
from flask import Flask, make_response
app = Flask(__name__)
@app.route('/')
def hello():
response = make_response("hello, world")
respon.headers["Cache-Control"]= 'public, amx-age=3600'
return response
if __name__ == '__main__':
app.run()
Caching Scenario
![[../images/20230914140127.png]] $$ L = 100K;bits; a = 15/sec; R = 1.54 MBps;
access link utilization = La/R = .97 LAN utilization = 0.0015 delay : 2sec + access link delay(minutes) + LAN delay $$
So slow. How will it be 해결?
- buy a faster link
high R
cost-ineffective - install a web cache #todo : make performance calculations
Conditional GET
Don't send object if cache has up-to-date cached version
- no object transmission delay
Client sends a If-modified-since header message of cache that they have 304 Not modified status code tells us "you don't need a newer one"
![[../images/20230914140912.png]]