Caching web contents in the browser

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    5 Favorites

    Caching web contents in the browser - Presentation Transcript

    1. www.devoxx.com
    2. Caching web contents in the browser
      • Nacho Coloma
      • Java Architect
      • Extrema Sistemas de
      • Información
    3. Overall Presentation Goal
      • Learn to think like the browser
    4. Speaker’s qualifications
      • Nacho Coloma is a Java Architect at Extrema Sistemas de Información
      • Since 1999 Nacho has designed air traffic systems, e-banking platforms, Document Management Systems and a full load of enterprise applications
      • … during which he has dealt with browsers more than he would like to :)
    5. Ye olde cache
      • We tend to avoid what we do not understand.
      Source: http://www.sawse.com/
      • 304 (Not Modified) responses
      • Expires headers
      • Strong and weak cache indicators
      Three things to know
      • Means “the browser already has the latest version of this file”
      • Will happen with every click unless Expires is used
      304
      • If the server includes Last-Modified the browser will include If-Modified-Since with each further request
      • Example: any static file with tomcat
      304 with Last-Modified Browser Server <No header> Last-Modified: Fri, 02 Nov 2007 00:36:01 GMT If-Modified-Since: Fri, 02 Nov 2007 00:36:01 GMT 200 OK / 304 Not Modified First request Subsequent requests
      • If server includes ETag the browser will include If-None-Match with each further request
      • Example: <inode>-<file-size>-<last-modified> with apache
      304 with ETag Browser Server <No header> ETag: 2e88051-8c-43f0b6dd972c0 If-None-Match: 2e88051-8c-43f0b6dd972c0 200 OK / 304 Not Modified First request Subsequent requests
      • Indicates for how long the file should not be retrieved again.
      • Cache-control (max-age)
          • http 1.1
          • seconds to expire
          • used by the browser
      Expires header Browser Server <No header> Expires: Mon, 15 Dec 2008 19:11:50 GMT Cache-Control: max-age=1209600 (No more requests until the resource expires) First request Subsequent requests
      • EExpires
          • http 1.0
          • Date
          • used by proxies installed by The Roman Empire.
      • Refresh : a new request will be sent for each file, ignoring the Expires header.
          • Any If-Modified-Since or If-None-Match headers will be sent.
          • The server may return a 304 response.
      • Shift + Refresh : a new request will be sent for each file, ignoring the Expires header.
          • Any If-Modified-Since or If-None-Match headers will not be sent .
          • The server cannot return a 304 response.
      The Refresh button
      • Weak : Last-Modified, default ETag implementations.
      • Strong : MD5, version numbers
      • Strong indicators can be inserted in the URL or used as ETag headers
      Weak and strong indicators
      • Version numbers
          • http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js
          • http://yui.yahooapis.com/2.6.0/build/reset/reset-min.css
      • Revision numbers
          • http://localhost/myentity?id=5&revision=20
      • MD5
          • http://localhost/images/photo.gif?checksum=9e0bee8ace86b2230140642adcf57c4c
      Strong indicators
      • Using strong indicators, you can set your Expires header to cache forever:
          • HTTP spec : 1 year
          • Yahoo! recommendation: 10 years
      • Use only with immutable resources
      Expires & strong indicators
    6. DEMO
      • You can try this yourself:
      • Go to
      • http://loom.extrema-sistemas.com/loomdemo/
      • Look the javascript file names that are retrieved; recognize the MD5 hash.
      • Look the files downloaded for the first and further requests (use LiveHttpHeaders or Firebug)
      • Click Refresh and see what happens
    7. Summary
      • The browser will ask for every resource unless you specify an Expires header
      • You may return 304 responses
      • You can use strong and weak cache indicators, in the URL or as HTTP headers
      • With strong cache indicators, you can cache immutable resources forever.
    8. Improve your performance!
      • Set your goal to < 1 sec per request
    9. Q&A
    10. Thanks for your attention
      • Nacho Coloma
      • [email_address]
      • http://icoloma.blogspot.com
      Source: http://www.sawse.com/ http://www.extrema-sistemas.com/

    + Ignacio ColomaIgnacio Coloma, 2 years ago

    custom

    1731 views, 5 favs, 2 embeds more stats

    Controlling what web contents are going to be cache more

    More info about this presentation

    © All Rights Reserved

    • Total Views 1731
      • 1560 on SlideShare
      • 171 from embeds
    • Comments 0
    • Favorites 5
    • Downloads 0
    Most viewed embeds
    • 168 views on http://icoloma.blogspot.com
    • 3 views on http://static.slideshare.net

    more

    All embeds
    • 168 views on http://icoloma.blogspot.com
    • 3 views on http://static.slideshare.net

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories