Server side
Internet technologies – Ohad © Server-side processing approaches Server-side UI generation PHP/ASP.net/JSP Single Page Application (aka SPA) Angular.js, Backbone, Ember Hybrid 2
Internet technologies – Ohad © Server-side UI generation example Inbox.*sp 3
Internet technologies – Ohad © Server-side UI generation example /preview/mail.*sp 4
Internet technologies – Ohad © Single Page Application 1. WS sends static HTML file 2. The HTML file build itself (via JavaScript) 3. The HTML file sends AJAX requests to the server 1. The server returns DATA not HTML 2. JavaScript parse the data and rerender the page 4. Advantages: 1. Less data over the network 2. Static resources are cacheable (CDNs) 3. Reduced operation cost 5
Internet technologies – Ohad © AJAX 6
Internet technologies – Ohad © JSON JavaScript Object Notation JSON vs. JavaScript Object Only 6 value types: json, array, number, string, boolean and null No function literal, No Undefined Keys must be String No identifier JSON is String. 7
Internet technologies – Ohad © JSON and AJAX JSON is a great format for AJAX responses. JSON.parse(str) – converts JSON to Object JSON.stringify(obj) - converts Object to JSON 8
Internet technologies – Ohad © Dynamic Web-Server Simple as Receives an HTTP request Do whatever processing you had like Reply with whatever HTTP response you had like REST standards Stateless server-side processing Cache as much as possible Meaningful HTTP request method 9
Internet technologies – Ohad © Dynamic Web-Server 10 Parameter
Cookies
Internet technologies – Ohad © Cookies Web Server can send a piece of information to the browser (this is the cookie) The browser save it as a file And send it back to the server (upon every new request) Cookie is a key/value thing 12
Internet technologies – Ohad © How? Utilizing HTTP headers 13
Internet technologies – Ohad © Response HTTP/ OK Content-type: text/html Set-Cookie: name=value Set-Cookie: name2=value2; Expires=Wed, 09 Jun :18:14 GMT 14
Internet technologies – Ohad © Every new request GET /spec.html HTTP/1.1 Host: Cookie: name=value; name2=value2 Accept: */* 15
Internet technologies – Ohad © Domain and Path Set specific domain and path Set-Cookie: someKey=someVal; Domain=.nba.com; Path=/jordan; Default to the domain and path of the object that was requested. 16
Internet technologies – Ohad © JavaScript.. One can access cookies by document.cookies Why this is a security vulnerability? 17
Internet technologies – Ohad © Security You can use HttpOnly No javascript access And Secure Only via SSL Set-Cookie: thisIs=good; HttpOnly; Secure; 18
Internet technologies – Ohad © Can we trust a cookie to stay there? NO! Why? Because The user can delete cookies.. The user can disable cookies… The user can switch machines… 19
Internet technologies – Ohad © Third-party cookie The browser is located in domain A But it loads image/ad from domain B Domain B sets a cookie… This is ½ legal… 20
Internet technologies – Ohad © Usage Remember Me? Any type of settings.. Tracking 21