HTTPandtheDynamicWeb

上传人:yx****d 文档编号:243017144 上传时间:2024-09-13 格式:PPT 页数:27 大小:230.50KB
返回 下载 相关 举报
HTTPandtheDynamicWeb_第1页
第1页 / 共27页
HTTPandtheDynamicWeb_第2页
第2页 / 共27页
HTTPandtheDynamicWeb_第3页
第3页 / 共27页
点击查看更多>>
资源描述
,*,Click to edit Master title style,Click to edit Master text styles bbbbbbbbbbb bbbbbbbbbb,Second level,Third level,Fourth level,Fifth level,HTTP and the Dynamic Web,1,How does the Web work?,The canonical example in your Web browser,Click,here,“here” is a Uniform Resource Locator (URL),It names the location of an object on a server.,courtesy of Geoff Voelker,2,In Action,Client,Server,Client uses DNS to resolves name of server (),Establishes an HTTP connection with the server over TCP/IP,Sends the server the name of the object (null),Server returns the object,HTTP,Voelker,3,Naming and URLs,How should objects be named?,URLs name objects and the,virtual,locations for those objects.,Location is a DNS name, so theres two more levels of naming and indirection under there.,Before hypertext we used to worry about,access transparency,.,Object name interpretation is up to the server, but its often a location in the local .,If an object moves, the URL breaks (,dangling reference,).,Location-independent names seem like the obvious way to go,Why dont we use them (e.g., URNs)?,How do we make them work, esp. in the face of mobility?,from Voelker, with additions,4,Protocols,What kind of transport protocol should the Web use?,HTTP 1.0,One TCP connection/object,Complaints: inefficient, slow, burdensome,HTTP 1.1,One TCP connection/many objects (persistent connections),Solves all problems, right? Huge amount of complexity,Clients, proxies, servers,How do they compare?,Protocol differences Krishnamurthy99, performance comparison Nielsen97, effects on servers Manley97, overhead of TCP connections Caceres98,HTTPS: HTTP with encryption,Voelker,5,HTTP in a Nutshell,HTTP supports request/response message exchanges of arbitrary length.,Small number of request types: basically GET and POST, with supplements.,object name, + content for POST,optional,query string,optional,request headers,Responses are self-typed objects (,documents,) with various attributes and tags.,optional,cookies,optional,response headers,GET /path/to/ HTTP/1.0,Client,Server(s),Content-type: MIME/html, Content-Length: 5000,.,6,Scalable Servers,Server,Of course, you are not the only person accessing the server,7,Web Caching,Gee, is there some way to offload those busy servers?,Use caches to exploit reference locality among clients,Clients,Proxy Cache,Servers,Voelker,8,Caching,How should we build caching systems for the Web?,Seminal paper Chankhunthod96,Proxy caches Duska97,Akamai hack Karger99,Cooperative caching Tewari99, Fan98,Wolman99,Popularity distributions Breslau99,Voelker,9,Issues for Web Caching,binding clients to proxies, handling failover,manual configuration, router-based “transparent caching”, WPAD (Web Proxy Automatic Discovery),proxy may confuse/obscure interactions between server and client,consistency management,At first approximation the Web is a wide-area read-only it is much more than that.,caching,responses,vs. caching documents,deltas,Mogul+Bala/Douglis/Misha/,prefetching, scale, request routing, scale, performance,Web caching vs.,content distribution,(e.g., Akamai),A few weeks from now.,10,HTTP 1.1,Specification effort started in W3C, finished in IETF.much later.,A number of research works influenced the specification.,HTTP 1.0 shows the importance of careful specification.,performance,persistent connections with pipelining,range requests, incremental update, deltas,caching,cache control headers,negotiation of content attributes and encodings,content attributes vs. transport attributes,transport encodings for transmission through proxies,Trailer,header and trailer headers,11,Persistent Connections,There are three key performance reasons for persistent connections:,connection setup overhead,TCP,slow start,: just do it and get it over with,pipelining as an alternative to multiple connections,And some new complexities resulting from their use, e.g.:,request/response framing and pairing,unexpected connection breakage,Just ask anyone from Akamai.,large numbers of active connections,How long to keep connections around?,These motivations and issues manifest in HTTP, but they are fundamental for request/response messaging over TCP.,12,Cookies,HTTP,cookies,(RFC2109) have brought us a better Web.,S,optionally includes arbitrary state as a cookie in a response.,Cookie is opaque to,C, but,C,saves the cookie.,C,sends the saved cookie in future requests to,S, and possibly to other servers as well.,Allows stateful servers for sessions, personalized content, etc.,But: cookies raise privacy and security issues.,What did,S,put in that cookie? Can anyone else see it? How much space does it take up on my disk that I paid soooo much for?,Cookies may allow third parties who are friends of,S,1,., S,N,to observe,C,s movements among,S,1,., S,N,.,Unverifiable transactions, e.g., DoubleClick and other ad services.,13,Unverifiable Transactions,Users may not know that they are interacting with DoubleClick.,Amazon and MyCFO trust DoubleClick, but client is ignorant.,The user visits pages at many sites that reference DoubleClick.,DoubleClicks cookie allows it to associate all the requests from a given user.,If the browser sends,Referer,headers, DoubleClick may gather information about all the sites the user visits that reference DoubleClick.,Client,doubleclick, akamai, etc.,GET,x,GET,y,GET,ad,Referer,ad,cookie,c,ad,GET,ad,cookie,c,Referer, Cache Consistency,“Requirements of performance, availability, and disconnected operation require us to relax the goal of semantic transparency.”,- HTTP 1.1 specification,Any caching/replication framework must take steps to ensure that the cache does not deliver old copies of modified objects.,Issues for cache consistency in the Web:,large number of clients/proxies,most static objects dont change very often,weaker consistency requirements,Stale information might be OK, as long as it is “not too stale”.,15,Cache Expiration and Validation,HTTP 1.0 cache control,Origin server may add a “freshness date” (,Expires,) response header.,.or the cache could determine expiration time heuristically.,Proxy must,revalidate,cache entry if it has expired.,Last-Modified,and,If-Modified-Since,Whose clock do we use for absolute expiration times?,Clients,Proxy,Origin Server,GET,x,GET,x,GET,x,GET,x,GET,x,If-Modified-Since,m,x, Last-Modified,m,Expires,t,304: Not Modified,16,Expiration and Validation in HTTP 1.1,HTTP 1.1 cache control allows origin server to:,use relative instead of absolute expiration times (,max-age,);,issue opaque,validators,(,ETag,for entity tag) instead of timestamps;,Origin server may specify which of several cached entries to use.,Clients,Proxy,Origin Server,GET,x,GET,x,GET,x,GET,x,GET,x,If-None-Match,v,x, ETag,v,max-age,t,304: Not Modified, ETag,v,Age ,t,Age = 0,17,Other 1.1 Cache Control Features,Client may specify that no caching is to occur.,private,or,no-store,Vary,headers allow server to specify that certain request headers must also match if the proxy deems a cached response valid.,language, character set, etc.,Server may specify that a response is not cacheable.,Pragma: no-cache,header since HTTP 1.0,Client may explicitly request the proxy to validate the response.,Pragma: no-cache,Proxy may/should/must tell client the age of a cached response.,Age,header,Proxy may/should/must tell client that it could not validate a non-fresh cached response with the origin server.,Warning,header,18,The Dynamic Web,HTTP began as a souped-up,FTP,that supports hypertext URLs.,Service builders rapidly began using it for dynamically-generated content.,Web servers morphed into,Web Application Servers,.,Common Gateway Interface (CGI),Java Servlets and JavaServer Pages (JSP),Microsoft Active Server Pages (ASP),Microsoft ASPs are not to be confused with,Application Service Providers,(ASPs).,GET program-name?arg1=x&arg2=y,Client,Server(s),Content-type: MIME/html, Content-Length: 5000,.,execute program,19,Multi-tier Services,Web application server,relational databases,Clients,HTTP,e.g., component “middleware”,transaction monitors,middle tiers,HTTP,RPC, RMI,IIOP,DCOM, EJB, CORBA, etc.,JNDI, JDBC,SQL,HTML+forms,applets,JavaScript,etc.,20,From Servers to Servlets,Servlets are dynamically loaded Java classes/objects invoked by a Web server to process requests.,Servlets are to servers as applets are to browsers.,Servlet support converts standard Web servers into extensible “Web application servers”.,designed as a Java-based replacement for CGI,Web server acts as a “connection manager” for the service body, which is specified as pluggable servlets.,interface specified by JavaSoft, supported by major servers,Servlets can be used in any kind of server (not just HTTP).,Invocation triggers are defined by server; the servlet does not know or care how it is invoked.,21,Anatomy of a Servlet,Servlet,ServletContext,init(ServletConfig config),String getServletInfo(),service(.),destroy(),network service,(servlet container),String getServerInfo(),Object getAttribute(name),String getMimeType(name),getResource*(name),log(string),ServletConfig,String getInitParameter(name),ServletContext getServletContext(),Enumeration getInitParameterNames(),GenericServlet,(implements),22,Invoking a Servlet,Servlet,service(ServletRequest, ServletResponse),ServletRequest,getContentLength, getContentType,getRemoteAddr, getRemoteHost,getInputStream,getParameter(name),getParameterValues(name),network service,ServletInputStream,readline(.),ServletResponse,setContentType(MIME type),getOutputStream(),ServletOutputStream,print(.),println(.),?,23,HTTP Servlets,HttpServlet,service(.),doGet(),doHead(),doPost().,HttpServletRequest,getCookies(),getRemoteUser(), getAuthType(),getHeader(name),getHeaderNames(),HttpSession getSession(),HttpServletResponse,addCookie(),setStatus(code, msg),setHeader(name, value),sendRedirect(),encodeUrl(),GenericServlet,ServletResponse,ServletRequest,24,HelloWorld Servlet,import java.io.*;,import javax.servlet.*;,public class HelloWorld extends GenericServlet,public void service(ServletRequest request, ServletResponse response),throws ServletException, IOException,.,public String getServletInfo(),return “Hello World Servlet;,25,HelloWorld Servlet (continued),public void service(ServletRequest request, ServletResponse response),throws ServletException, IOException,ServletOutputStream output = response.getOutputStream();,String fromWho = request.getParameter(“from);,response.setContentType(“text/html);,if (fromWho = null) ,output.println(“Hello world!);, else ,output.println(“Hello world from ,+ fromWho + “);,26,Example 1: Invoking a Servlet by URL,Most servers allow a servlet to be invoked directly by URL.,client issues HTTP GET,e.g.,servlet specified by HTTP POST,e.g., with form data,From : , ,generates a URL-encoded query,string, e.g., “?from=me,”,27,
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 图纸专区 > 大学资料


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!