1 Caching in HTTP Representation and Management of Data on the Internet.

Slides:



Advertisements
Similar presentations
Cookies, Sessions. Server Side Includes You can insert the content of one file into another file before the server executes it, with the require() function.
Advertisements

PACS – 06/21/14 1 Cache? What is caching? A way to increase the average rate of a process by preferentially using a copy of data in a faster, closer, probably.
1 11 Web Caching Web Protocols and Practice. 2 Topics Web Protocols and Practice WEB CACHING  Cache Definition  Goals of Web Caching  Motivations for.
1 Caching in HTTP Representation and Management of Data on the Internet.
Internet Networking Spring 2006 Tutorial 12 Web Caching Protocols ICP, CARP.
HTTP – HyperText Transfer Protocol
1 HTTP – HyperText Transfer Protocol Part 1. 2 Common Protocols In order for two remote machines to “ understand ” each other they should –‘‘ speak the.
HTTP HyperText Transfer Protocol Part 2.
How the web works: HTTP and CGI explained
What’s a Web Cache? Why do people use them? Web cache location Web cache purpose There are two main reasons that Web cache are used:  to reduce latency.
HTTP HyperText Transfer Protocol.
1 HTTP - Hypertext Transfer Protocol Arthur : Yigal Eliaspur Date :
Web, HTTP and Web Caching
Application Layer  We will learn about protocols by examining popular application-level protocols  HTTP  FTP  SMTP / POP3 / IMAP  Focus on client-server.
HTTP HyperText Transfer Protocol Part 3.
1 The World Wide Web. 2  Web Fundamentals  Pages are defined by the Hypertext Markup Language (HTML) and contain text, graphics, audio, video and software.
2/9/2004 Web and HTTP February 9, /9/2004 Assignments Due – Reading and Warmup Work on Message of the Day.
Hypertext Transport Protocol CS Dick Steflik.
Nikolay Kostov Telerik Corporation
Web Cache. Introduction what is web cache?  Introducing proxy servers at certain points in the network that serve in caching Web documents for faster.
Cookies COEN 351 E-commerce Security. Client / Session Identification HTTP does not maintain state. State Information can be passed using: HTTP Headers.
1 Caching  Temporary storage of frequently accessed data (duplicating original data stored somewhere else)  Reduces access time/latency for clients 
HyperText Transfer Protocol
Krerk Piromsopa. Web Caching Krerk Piromsopa. Department of Computer Engineering. Chulalongkorn University.
HTTP Protocol Specification
Web Caching: Replication on the World Wide Web Jonathan Bulava CSC8530 – Distributed Systems Dr. Paul Schragger.
CSC 2720 Building Web Applications Getting and Setting HTTP Headers (With PHP Examples)
1 Lecture #7-8 HTTP – HyperText Transfer Protocol HAIT Summer 2005 Shimrit Tzur-David.
CP476 Internet Computing Lecture 5 : HTTP, WWW and URL 1 Lecture 5. WWW, HTTP and URL Objective: to review the concepts of WWW to understand how HTTP works.
Rensselaer Polytechnic Institute Shivkumar Kalvanaraman, Biplab Sikdar 1 The Web: the http protocol http: hypertext transfer protocol Web’s application.
Week 11: Application Layer1 Web and HTTP First some jargon r Web page consists of objects r Object can be HTML file, JPEG image, Java applet, audio file,…
5 Chapter Five Web Servers. 5 Chapter Objectives Learn about the Microsoft Personal Web Server Software Learn how to improve Web site performance Learn.
CSE 154 LECTURE 12: COOKIES. Including files: include include("filename"); PHP include("header.html"); include("shared-code.php"); PHP inserts the entire.
DBI Representation and Management of Data on the Internet.
HTTP and Web Server HTTP HTTP is the protocol used by Web applications to exchange information. HTTP is a simple stateless request-response protocol.
Lecture 8 – Cookies & Sessions SFDV3011 – Advanced Web Development 1.
Web Server Design Week 4 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 2/03/10.
CIS679: Lecture 13 r Review of Last Lecture r More on HTTP.
HTTP support for caching & replication. Conditional requests Server executes conditional request. Responds with a message body only if the condition is.
Web Database Programming Week 7 Session Management & Authentication.
A Little Bit About Cookies Fort Collins, CO Copyright © XTR Systems, LLC A Little Bit About Cookies Instructor: Joseph DiVerdi, Ph.D., M.B.A.
© 2010 Computer Science Faculty, Kabul University HTTP CONTINUED… 4 TH LECTURE 2, May, 2010 Baseer Ahmad Baheer.
Web Cache Consistency. “Requirements of performance, availability, and disconnected operation require us to relax the goal of semantic transparency.”
On The Cooperation of Web Clients and Proxy Caches Yiu Fai Sit, Francis C.M. Lau, Cho-Li Wang Department of Computer Science The University of Hong Kong.
Cookies COEN 351 E-commerce Security. Client / Session Identification HTTP Headers Client IP Address HTTP User Login FAT URLs Cookies.
CP476 Internet Computing CGI1 Cookie –Cookie is a mechanism for a web server recall info of accessing of a client browser –A cookie is an object sent by.
HTTP evolution - TCP/IP issues Lecture 4 CM David De Roure
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
HTTP Here, we examine the hypertext transfer protocol (http) – originally introduced around 1990 but not standardized until 1997 (version 1.0) – protocol.
EE 122: Lecture 21 (HyperText Transfer Protocol - HTTP) Ion Stoica Nov 20, 2001 (*)
ITM © Port,Kazman 1 ITM 352 Cookies. ITM © Port,Kazman 2 Problem… r How do you identify a particular user when they visit your site (or any.
1 COMP 431 Internet Services & Protocols HTTP Persistence & Web Caching Jasleen Kaur February 11, 2016.
COMP2322 Lab 2 HTTP Steven Lee Jan. 29, HTTP Hypertext Transfer Protocol Web’s application layer protocol Client/server model – Client (browser):
HTTP HyperText Transfer Protocol.
Unit-6 Handling Sessions and Cookies. Concept of Session Session values are store in server side not in user’s machine. A session is available as long.
Overview on Web Caching COSC 513 Class Presentation Instructor: Prof. M. Anvari Student name: Wei Wei ID:
Week 11: Application Layer 1 Web and HTTP r Web page consists of objects r Object can be HTML file, JPEG image, Java applet, audio file,… r Web page consists.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
1 Chapter 22 World Wide Web (HTTP) Chapter 22 World Wide Web (HTTP) Mi-Jung Choi Dept. of Computer Science and Engineering
1 HTTP – HyperText Transfer Protocol Representation and Management of Data on the Internet.
© Janice Regan, CMPT 128, Jan 2007 CMPT 371 Data Communications and Networking HTTP 0.
What’s Really Happening
Hypertext Transfer Protocol
WWW and HTTP King Fahd University of Petroleum & Minerals
HTTP request message: general format
Caching Temporary storage of frequently accessed data (duplicating original data stored somewhere else) Reduces access time/latency for clients Reduces.
COMP2322 Lab 2 HTTP Steven Lee Feb. 8, 2017.
ITM 352 Cookies.
Web Caching? Web Caching:.
HyperText Transfer Protocol
Presentation transcript:

1 Caching in HTTP Representation and Management of Data on the Internet

2 Reasons for Using Web Caches Reduce Latency –Since the cache is closer to the client, it takes less time for the client to get the object and display it Save bandwidth –Since each object is only gotten from the server once, it reduces the amount of bandwidth used by a client

3 Type of Web Caches Browser Caches –A portion of the hard disk is used to store objects that have already been displayed –If an objected is requested again (for example, by hitting the “ back ” button), the request is served from the browser cache Proxy Caches –These are shared caches – they serve many users

4 For example, how much traffic is saved if it is not required to send the Google icon with each search result?

5 Caching Improves Performance in Two Ways In some cases, caching eliminates the need to send requests by using an expiration mechanism In other cases, caching eliminates the need to send full responses by using a validation mechanism

6 An Example of Using a Validation Mechanism client server cache Client: GET /fruit/apple.gif Server responds with Last-Modified-Date:... Server returns either 304 Not Modified or object Client sends GET /fruit/apple.gif … If-Modified-Since: … Client caches object and last-modified-date

7 Proxy Caches client server proxy server GET /fruit/apple.gif

8 Benefit of Caching client 10Mbps LAN RR 1.5Mbps server 15 req/sec 100Kbits/req proxy server 50% hit rate is possible, because the cache is shared by many users and, therefore, there is a large number of shared hits Internet

9 Points to Consider When Designing a Web Site Caches can help the Web site to load faster Caches may “ hide ” the users of the Web site, making it difficult to see who is using the site Caches may serve content that is out of date, or stale

10 The Risk in Caching Response might not be “ semantically transparent ” –the response is different from what would have been returned by the origin server The cache should verify that the copy is fresh The copy is stale if it is not fresh

11 Cases Where Objects are not Cached In the following cases, objects are not cached: –The object ’ s header tell the cache not to keep the object –The object has neither a validator nor a Last-Modified value –The object is authenticated or secured

12 Fresh Objects are Served from the Cache An object is fresh in the following cases: –The object has an expiry time or other age- controlling directive, and is still in the fresh period –The browser cache has already seen the object, and has been set to check once a session –A proxy cache has received the object recently, and the object was modified relatively long ago (this is a heuristic – see later)

13 Validating an Object If the object is stale (i.e., not fresh), the cache will ask the origin server to validate the object In response, the origin server will either –tell the cache that the object has not changed, or –send a new copy of the object to the cache

14 The Expires HTTP Header A response may include an Expires header: Expires: Fri, 30 Oct :19:41 GMT If an expiry time is not specified, the cache can heuristically estimate the expiry time

15 A Possible Heuristic If the cache received the object 10 hours after it was last modified, then it can heuristically determine that the expiry time is 1 hour after it has received it In general, add 10% of the interval between the last-modification time (given by the Last-Modified header) and the time it was received

16 Cache-Control Headers (Introduced in HTTP 1.1) The following are possible cache-control headers in responses max-age=[seconds] –Specifies the maximum amount of time that an object will be considered fresh (similar to the Expires header) s-maxage=[seconds] –Similar to max-age, except that it only applies to proxy (shared) caches

17 More Cache-Control Headers must-revalidate –Tell caches that they must obey any freshness information provided with the object (HTTP allows caches to take liberties with the freshness of objects) proxy-revalidate –Similar to must-revalidate, except that it only applies to proxy (shared) caches

18 No-Cache Some cache-control header are meaningful in either responses or requests No-cache –In a response, it means not to cache the object –In a request, it means to bring a copy from the origin server (i.e., not to use a cache)

19 Who Adds Cache-Control Headers? The server –The configuration of the server determines which cache-control headers are added to responses –The author of the page can add headers by means of the.htaccess file (only in the Apache server) The author of the page –

20 Validators A validator is any mechanism that may help in determining whether a copy is fresh or stale –A strong validator is, for example, a counter that is incremented whenever the resource is changed –A weak validator is, for example, a counter that is incremented only when a significant change is made For example, if the only change in the site is the number of visitors …

21 Last-Modified Header The most common validator is the time that the document last changed, the last-modified time –It is given by the Last-Modified header –This header should be included in every response –It is a weak validator if an object can change more than once within a one- second interval

22 ETag (Entity Tag) ETag is a validator generated by the server (i.e., unique identifier) –It is part of the HTTP 1.1 specification (not available in HTTP 1.0) The preferred behavior for an HTTP 1.1 origin server is to send both a strong entity tag and a Last-Modified value

23 Conditional Requests Some conditional headers are –If-Modified-Since –If-Unmodified-Since –If-None-Match These headers are used to validate an object (i.e., check with the origin server whether the object has changed)

24 HTTP/ Not Modified Date: Fri, 31 Dec :59:59 GMT [blank line] If-Modified-Since Header The If-Modified-Since : header is used with a GET request If the requested resource has been modified since the given date, the server returns the resource as it normally would (i.e., header is ignored) Otherwise, the server returns a 304 Not Modified response, including the Date: header, but with no message body

25 If-Unmodified-Since Header The If-Unmodified-Since: header can be used with any method If the requested resource has not been modified since the given date, the server returns the resource as it normally would Otherwise, the server returns a 412 Precondition Failed response HTTP/ Precondition Failed [blank line]

26 If-None-Match Header If the ETag matches when an If-None- Match header is specified, then the object is really the same and is not returned

27 Old Way not to Use the Cache The Pragma: no-cache request header indicates that the request should not be satisfied from a cache Same as the no-cache cash-directive Directive applies to any recipient along the request/response chain Don’t use pragma – only applies to requests and exists just for compatibility with HTTP 1.0

28 Cooperative Caching

29 Cooperative Caching (cont.) Higher level cache (e.g., national cash) –larger user population –higher hit rates Multiple Web cashes which cooperate  Improve overall performance Cooperative cashes usually built from clusters –divide the traffic overhead –improve storage capacity

30 Cooperative Caching (cont.) Which cashes should be asked for a particular doc? Hash routing (of URLs) – an object will not be present in more than one cash

31 Hop by Hop HTTP/1.1 introduces the concept of hop-by-hop headers: –Message headers that apply only to a given connection, and not to the entire path –It enables much more power with the usage of proxies (cashes) –The headers give information that is directed to the proxies on the way to the client

32 Chunked Encoding Music, video clips and other multimedia content is sent to the client by chunks of data Among other problems, are the difficulties that –One data chunk varies in size and composition from the next –The size of the chunks may not be specified in the headers and so it may be difficult to recognize the end of a chunk –There should be a way to deal with ‘ infinite ’ responses in order to deal with data chunks that are very big (or with infinite files that are created dynamically)

33 Compression Most image formats (GIF, JPEG, MPEG) are precompressed Many other data types used in the Web are not precompressed Compression could save almost 40% of the bytes sent via HTTP There is a need for negotiating the type of encoding of the compressed resource

34 Compression (cont.) Client sends the header Accept-Encoding –The header indicates the content-encodings that the client can handle and the ones that the client prefers Server Sends –Content-Encoding header – for end-to-end encoding indication –Transfer-Encoding header – for hop-to-hop encoding indication (supported only in HTTP/1.1)

35 Authentication Many sites require users to provide a username and password in order to access the documents housed on the server This requirement provides a mechanism for keeping track of users (more than just a security mechanism)

36 Authentication Client sends ordinary request message Server responds with –401 Authorization Required status code –WWW-Authenticate header which specifies how to perform authentication Client resends the requested message, but this time including the Authorization header (e.g., user- name & password) Client continues to add this header for each following request to that server

37 Authentication client server GET ~dbi/getGrade.jspAuthorization Required GET ~dbi/getGrade.jsp Authorization: user snoopy:passwordofsnoopy Response

38 Cookies Cookies are an alternative way to identify browsers (i.e., clients) Cookies are essentially small files that are saved in the file system of the client A cookie can store information on the client and thus helps in recognizing the client and getting required information about the client How can cookies solve the problem that HTTP is stateless?

39 Cookies Server response includes the Set-cookie header that has the attributes –name = VALUE –expires = DATE STRING –domain = DOMAIN NAME –path = PATH –secure Clients returns a cookie only to a server with matching URL (the server that put the cookie)

40 Cookies Example: –Client contacts a web site for the first time –Server response includes the header: Set-cookie : –Client stores the cookie value and the server name in a special “ cookie file ” –For each further request for that server, the client will add the header Cookie :

41 Cookies (cont.) Usage: –Server requires authentication, but doesn ’ t want to hassle a user with a user-name and password –Remembering user ’ s preferences for advertising –Cookies enable creating a virtual shopping cart Problems –Users who access the same site from different machines –Privacy

42 Links For specifications and additional information: – – – – mlhttp://wdvl.com/Internet/Protocols/HTTP/article.ht ml –Caching Tutorial for Web Authors and Webmasters (