Presentation is loading. Please wait.

Presentation is loading. Please wait.

10/13/2015 ©2006 Scott Miller, University of Victoria 1 Content Serving Static vs. Dynamic Content Web Servers Server Flow Control Rev. 2.0.

Similar presentations


Presentation on theme: "10/13/2015 ©2006 Scott Miller, University of Victoria 1 Content Serving Static vs. Dynamic Content Web Servers Server Flow Control Rev. 2.0."— Presentation transcript:

1 10/13/2015 ©2006 Scott Miller, University of Victoria 1 Content Serving Static vs. Dynamic Content Web Servers Server Flow Control Rev. 2.0

2 10/13/2015 ©2006 Scott Miller, University of Victoria 2 Static vs. Dynamic Content Static Content: Content that only changes when the site administrator changes it –Web pages, CSS, frame based sites, etc. –Includes “Dynamic looking” sites that have JavaScript client-side handlers Dynamic Content: Customized content based on user input –May be input from older session (via cookies) –Query data, DB lookups, Preferences (portal), Secure logins for commerce, etc. –Generated via Web Application

3 10/13/2015 ©2006 Scott Miller, University of Victoria 3 Static vs. Dynamic Content Web Server: Program (daemon) that listens for HTTP requests (on port 80) –Serves static HTML documents File on a file system mapped to the server’s root –Calls Application Server as needed Application Server: –Program called upon by a Web Server –Dynamically generates predefined content as its output HTML, XHTML, ASCII, etc.

4 10/13/2015 ©2006 Scott Miller, University of Victoria 4 Web Server – Little Bit ‘o Practical Domains are simply directory structures “mapped” off the hard disk. / / web img note cgi-bin Hard drive http://www.foo.org/ * cgi-bin would not be found!

5 10/13/2015 ©2006 Scott Miller, University of Victoria 5 Web Server – Little Bit ‘o Practical Virtual Hosting – The Web Server is configured to read a different directory structure as a domain’s root. / / tim img note ryan Hard drive http://www.tim.biz/http://www.ryan.biz/

6 10/13/2015 ©2006 Scott Miller, University of Victoria 6 Get to know your UNIX! *NIX permissions are an effective shield against content others shouldn’t have. –Resources posted, but not yet available to user Know your directory structure for web serving (know what structure you will use to host site(s) and where to locate it/them. Know how to edit remotely via command line – especially know basic vi.

7 10/13/2015 ©2006 Scott Miller, University of Victoria 7 Client-Server Web Server Interaction Web Server App Server HTTPCGI stdin HTTP Request CGI stdout Response HTML, text, Java, etc.

8 10/13/2015 ©2006 Scott Miller, University of Victoria 8 Web Server Content HTML, CSS, XHTML, etc. Binary files (any binaries to be downloaded) Java Applets JavaScript enabled content Media rendering directly from MIME Types

9 10/13/2015 ©2006 Scott Miller, University of Victoria 9 Bandwidth management Client side scripting: –ex. Text viewer (zoomed in) for visually impaired Let them scroll around and zoom on client side after getting document from server Caching: Only get a resource if it has changed Compression: Transmit less bits through compression

10 10/13/2015 ©2006 Scott Miller, University of Victoria 10 Dynamic Content Serving CGI Rev 2.0

11 10/13/2015 ©2006 Scott Miller, University of Victoria 11 Application Servers If a Web Server only hosts static content, how do we get dynamic content? –APPLICATION SERVER! Usually a plug-in to a web server; still a distinct program Communicates with web server to perform calculations or action and return result Can consist of any language

12 10/13/2015 ©2006 Scott Miller, University of Victoria 12 Server-Server communications Web Server App Server HTTPCGI stdin HTTP Request CGI stdout Response HTML, text, Java, etc.

13 10/13/2015 ©2006 Scott Miller, University of Victoria 13 CGI – Common Gateway Interface CGI is a protocol –Can be written in any language that can read from stdin, write to stdout and can read environment variables TRANSLATION: Pretty much any language you like Referenced in url –e.g. As a directory  /cgi-bin/ Launched from web server as a separate process to handle the request

14 10/13/2015 ©2006 Scott Miller, University of Victoria 14 CGI Protocol How does web server pass information to the application server? –Environment variables –stdin/stdout CGI is about sending back the “Request Context” to the application server –HTTP request –HTTP headers –parameters

15 10/13/2015 ©2006 Scott Miller, University of Victoria 15 CGI Protocol – HTTP Headers HTTP HeaderEnvironment Variable Content-LengthCONTENT_LENGTH Content-TypeCONTENT_TYPE User-AgentHTTP_USER_AGENT HostHTTP_HOST *HTTP_*

16 10/13/2015 ©2006 Scott Miller, University of Victoria 16 CGI Protocol- Example GET /cgi-bin/Login.pl?username=Scott&pwd=foo HTTP/1.1 Host: www.uvic.ca Cookie: loginAttempt=3 Cookie: config=1 Env. VariableValue HTTP_Hostwww.uvic.ca QUERY_STRINGusername=Scott&pwd=foo HTTP_COOKIEloginAttempt=3;config=1

17 10/13/2015 ©2006 Scott Miller, University of Victoria 17 CGI Protocol – Continued The body of a HTTP request is written to stdin of the CGI process –POST method: body contains the query parameters THEREFORE: CGI script must look query parameters in 2 places –If GET: QUERY_STRING –If POST: stdin will contain CONTENT_LENGTH bytes

18 10/13/2015 ©2006 Scott Miller, University of Victoria 18 CGI Protocol – Finishing Touches The CGI program writes the full HTTP response to stdout –Includes HTTP headers –In Other Words: Output of CGI program is a complete HTTP response

19 10/13/2015 ©2006 Scott Miller, University of Victoria 19 CGI Calling Each CGI process is created from scratch by the web server for each request –Environment variables are ONLY for one request –CGI process terminates once it is done writing output

20 10/13/2015 ©2006 Scott Miller, University of Victoria 20 CG-I-Don’t-Know-About-This… Having to output raw HTML in CGI programs is: 1.A maintenance nightmare!!! 2.No separation of content from presentation –1 & 2 distinguish this approach as terrible Software Engineering. Why? Doesn’t scale well –New process for EACH request

21 10/13/2015 ©2006 Scott Miller, University of Victoria 21 CGI Key Ideas Output of CGI is HTML to be displayed on the browser What HTML contains is determined when the program runs (DYNAMIC CONTENT) as a function of query parameters In practice: the strings of HTML your CGI program generates will contain variables populated by queries


Download ppt "10/13/2015 ©2006 Scott Miller, University of Victoria 1 Content Serving Static vs. Dynamic Content Web Servers Server Flow Control Rev. 2.0."

Similar presentations


Ads by Google