1 / 15

REST & Caching

REST & Caching. Scaling like the internets. HTTP and REST. REST is an architectural style Draws and relies heavily on HTTP HTTP just scales. HTTP and Caching. Conditional GET Caching intermediaries Web Server Caching Data Caching. SOAP.

zeroun
Download Presentation

REST & Caching

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. REST & Caching Scaling like the internets

  2. HTTP and REST • REST is an architectural style • Draws and relies heavily on HTTP • HTTP just scales

  3. HTTP and Caching • Conditional GET • Caching intermediaries • Web Server Caching • Data Caching SOAP Because SOAP uses POST and POST is unsafe to cache *Except Data Caching

  4. Server-side Caching • HttpContext.Current.Cache • Velocity • IIS kernel and user mode caching

  5. DEMO IIS Caching

  6. Conditional GET (304 Not Modified) • This may be the most important status code of them all • This one of the ways the web scales • REST piggybacks on this • Saves bandwidth, as well as processing power on both server and client • Works like this • Server sends resource • Headers include “extra” information • Client asks for resource again (GET) • Sends the “extra” information (condition) • If request meets condition, server returns 304 • If request doesn’t, server returns the resource again

  7. Last Modified • One way to implement conditional GET • Server sets Last-Modified header with timestamp • Client uses If-Modified-Since header value • If resource hasn’t changed, server returns a 304

  8. ETag • Another way to implement conditional GET • Server sets an opaque value for the ETag header • Generally implementation is to take a hash value of some or all of the bytes of the resource • Client sends If-None-Match header

  9. Generating ETag ETag is opaque to user agent: meaningful to service string GenerateETag(User u) { byte[] bytes = Encoding.UTF8.GetBytes(u.UserId + u.LastModified.ToString()); byte[] hash = MD5.Create().ComputeHash(bytes); string etag = Convert.ToBase64String(hash); return etag; } void SetETag(string etag) { OutgoingWebResponseContext ctx = WebOperationContext.Current.OutgoingResponse; ctx.ETag = etag; }

  10. DEMO Conditional GET

  11. Summary • REST is an architectural style for building client-server applications • REST relies on HTTP • HTTP scales because of caching

  12. References • HTTP http://www.w3.org/Protocols/ • Conditional GET http://ftp.ics.uci.edu/pub/websoft/caching.html • ETags http://bitworking.org/news/150/REST-Tip-Deep-etags-give-you-more-benefits • REST Starter Kit - HttpClient

  13. Please Complete an Evaluation FormYour feedback is important! • Evaluation forms can be found on each chair • Temp Staff at the back of the room have additional evaluation form copies

  14. © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

More Related