Presentation is loading. Please wait.

Presentation is loading. Please wait.

HTTP request message: general format

Similar presentations


Presentation on theme: "HTTP request message: general format"— Presentation transcript:

1 HTTP request message: general format

2 Uploading form input Post method: Web page often includes form input
Input is uploaded to server in entity body URL method: Uses GET method Input is uploaded in URL field of request line:

3 Method types HTTP/1.0 GET POST HEAD HTTP/1.1 GET, POST, HEAD PUT
asks server to leave requested object out of response HTTP/1.1 GET, POST, HEAD PUT uploads file in entity body to path specified in URL field DELETE deletes file specified in the URL field

4 HTTP response message status line (protocol status code status phrase)
header lines data, e.g., requested HTML file Data………………….

5 HTTP response status codes
In first line in server->client response message. A few sample codes: 200 OK request succeeded, requested object later in this message 301 Moved Permanently requested object moved, new location specified later in this message (Location:) 400 Bad Request request message not understood by server 404 Not Found requested document not found on this server 505 HTTP Version Not Supported

6 User-server state: cookies
Many major Web sites use cookies Four components: 1) cookie header line in the HTTP response message 2) cookie header line in HTTP request message 3) cookie file kept on user’s host and managed by user’s browser 4) back-end database at Web site Example: Susan access Internet always from same PC She visits a specific e- commerce site for first time When initial HTTP requests arrives at site, site creates a unique ID and creates an entry in backend database for ID

7 Cookies: keeping “state” (cont.)
client server usual http request msg usual http response + Set-cookie: 1678 cookie: 1678 usual http response msg cookie- specific action spectific Cookie file ebay: 8734 server creates ID 1678 for user entry in backend database Cookie file amazon: 1678 ebay: 8734 access one week later: access Cookie file amazon: 1678 ebay: 8734

8 Cookies (continued) Cookies and privacy:
aside Cookies and privacy: cookies permit sites to learn a lot about you you may supply name and to sites search engines use redirection & cookies to learn yet more advertising companies obtain info across sites What cookies can bring: authorization shopping carts recommendations user session state (Web ) Do cookies compromise security? Can it be used for authentication?

9 Web caches (proxy server)
Goal: satisfy client request without involving origin server user sets browser: Web accesses via cache browser sends all HTTP requests to cache object in cache: cache returns object else cache requests object from origin server, then returns object to client origin server Proxy server HTTP request HTTP request client HTTP response HTTP response HTTP request HTTP response client origin server Your Web request may be intercepted using a transparent TCP proxy!

10 More about Web caching Cache acts as both client and server
Typically cache is installed by ISP (university, company, residential ISP) Why Web caching? Reduce response time for client request. Reduce traffic on an institution’s access link. Internet dense with caches enables “poor” content providers to effectively deliver content (but so does P2P file sharing)

11 Types of Web Caches User Agent Cache (Browser Cache)
Single user Shared Cache (Proxy Cache) Multi-user Gateway Cache

12 Caching example Assumptions origin average object size = 100,000 bits
avg. request rate from institution’s browsers to origin servers = 15/sec delay from institutional router to any origin server and back to router = 2 sec Consequences utilization on LAN = 1.5Mbps/10Mbps = 15% utilization on access link = 100% total delay = Internet delay + access delay + LAN delay = 2 sec + minutes + milliseconds origin servers public Internet institutional network 10 Mbps LAN 1.5 Mbps access link cache

13 Caching example (cont)
origin servers Possible solution increase bandwidth of access link to, say, 10 Mbps Consequences utilization on LAN = 15% utilization on access link = 15% Total delay = Internet delay + access delay + LAN delay = 2 sec + msecs + msecs often a costly upgrade public Internet 10 Mbps access link institutional network 10 Mbps LAN institutional cache

14 Caching example (cont)
origin servers Install cache suppose hit rate is 0.4 Consequence 40% requests will be satisfied almost immediately 60% requests satisfied by origin server utilization of access link reduced to 60%, resulting in negligible delays (say 10 msec) total avg delay = Internet delay + access delay + LAN delay = .6*(2.01) secs + milliseconds < 1.4 secs public Internet 1.5 Mbps access link institutional network 10 Mbps LAN institutional cache

15 Conditional GET server cache
Goal: don’t send object if cache has up-to-date cached version cache: specify date of cached copy in HTTP request If-modified-since: <date> server: response contains no object if cached copy is up-to- date: HTTP/ Not Modified HTTP request msg If-modified-since: <date> object not modified HTTP response HTTP/1.0 304 Not Modified HTTP request msg If-modified-since: <date> object modified HTTP response HTTP/ OK <data>

16 Controlling Cache HTML Meta Tags HTTP Headers
Written in <head> section of an HTML page. Can mark expiration date or as uncacheable. Only used by some browser caches and not seen by proxy caches. HTTP Headers Automatically created by Web server. Sent before HTML. Seen by browser and proxy caches.

17 HTTP Defining Mechanisms
Freshness – Content is able to be loaded from cache without having to check with the original server. Validation – The process of confirming with the original server whether or not cached content is still valid to load.

18 HTTP Response Headers Example
HTTP/ OK Date: Fri, 30 Oct :19:41 GMT Server: Apache/1.3.3 (Unix) Cache-Control: max-age=3600, must-revalidate Expires: Fri, 30 Oct :19:41 GMT Last-Modified: Mon, 29 Jun :28:12 GMT ETag: "3e fbbc" Content-Length: 1040 Content-Type: text/html Validation Freshness

19 Expires Header and Freshness
Expires: Fri, 30 Oct :19:41 GMT Indicates how long the representation is fresh. After this time passes, the cache will communicate with the original server to see if there have been any changes. Beneficial for static page images as well as continually changing content. Web server and cache must be synchronized.

20 Cache-Control Header and Freshness
Cache-Control: max-age=3600, must-revalidate Gives control beyond Expires header. Cache control response-headers: max-age=[seconds] s-maxage=[seconds] public no-cache no-store must-revalidate proxy-revalidate

21 Last-Modified and Validation
Last-Modified: Mon, 29 Jun :28:12 GMT Validate cache by looking at the last time the document was altered (Last-Modified). If-Modified-Since request is sent to the original server. If changes have been made since the date given, the entire document is returned. Otherwise, the cached document can be loaded.

22 ETag and Validation Unique identifiers created by server.
ETag: "3e fbbc" Unique identifiers created by server. Changed each time the representation is altered on the original server. If-None-Match, request is sent to server and a simple comparison is used to validate the content.

23 Content Delivery Network (CDN)
4a. Get embedded documents from local cache or server (if not already cached) Cache CDN server 4b. Embedded documents 5. Embedded documents 3. Get embedded documents 1. Get base documents Client Original server 2. Document with refs to embedded documents Cache producer within Akamai CDN

24 References Nottingham, Mark. “Caching Tutorial: for Web Authors and Webmasters.” July < Tanenbaum, Andrew S. Distributed Systems: Principles and Paradigms. New Jersey: Prentice- Hall, 2002. “Web cache.” Wikipedia. <


Download ppt "HTTP request message: general format"

Similar presentations


Ads by Google