Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Browser Caching and You - A Love Story

Browser Caching and You - A Love Story

Over time, Web developers have feared, hated and loved Web caching, at times trying to kill it, at others professing undying love. Mark Nottingham (chair of the IETF HTTPbis Working Group and author of its revised Web Caching specification) will examine how browsers (mis)-treat your content today, as well as where your relationship with browser caching might go in the future.

Mark Nottingham

October 15, 2010
Tweet

More Decks by Mark Nottingham

Other Decks in Technology

Transcript

  1. Browser Caching & You
    (a love story)
    Mark Nottingham / mnot.net

    View Slide

  2. At First Sight:
    The Honeymoon

    View Slide

  3. EMPTY
    FULL
    http://www.yuiblog.com/blog/2007/01/04/performance-research-part-2/

    View Slide

  4. View Slide

  5. Relationship Trouble

    View Slide

  6. http://www.websiteoptimization.com/speed/tweak/average-web-page/

    View Slide

  7. Mozilla: 50MB
    IE: 10% (max 1G)
    Safari: ??
    Chrome: 8-250M?

    View Slide

  8. Mozilla: 100 pages

    View Slide

  9. Mozilla: 16384 entries
    89 // Min and max values for the number of records in the DiskCachemap
    90 #define kMinRecordCount 512
    91
    92 #define kSeparateFile 0
    93 // #define must always be <= 65535KB, or overflow. See bug 443067 Comment 8
    94 #define kMaxDataFileSize 5 * 1024 * 1024 // 5 MB (in bytes)
    95 #define kBuckets (1 << 5) // must be a power of 2!
    (~230 pages)

    View Slide

  10. Cache-Control: max-age=0,
    no-cache, no-store,
    private, pre-check=0,
    post-check=0

    View Slide

  11. “Maybe we should
    start seeing other
    people...”

    View Slide

  12. HTML5 AppCache

    View Slide

  13. View Slide

  14. • privacy concerns (“EverCookie”)
    • relationship with HTTP caching is
    poorly de^ined
    • designed for of^line use

    View Slide

  15. Getting to know
    each other

    View Slide

  16. View Slide

  17. max-age / expires
    Chrome 6
    IE7

    View Slide

  18. max-age / expires
    Safari 5.0.2
    Take-away: Cache timing is OK, but not exact

    View Slide

  19. no-cache no-store
    Take-away: no-store is enough

    View Slide

  20. Age
    IE8

    View Slide

  21. Date
    Safari 5.0.2
    IE (any)

    View Slide

  22. pre-check, post-check
    Take-away: max-age=0, pre-check=0, post-check=0
    is a really bad idea.
    IE (most)

    View Slide

  23. Where is this thing going?
    (“the talk”)

    View Slide

  24. • Fixing Bugs
    • Sizing Caches Appropriately
    • Replacement Algorithms

    View Slide

  25. stale-while-revalidate
    cache

    View Slide

  26. stale-if-error

    View Slide

  27. Cache Invalidation

    View Slide

  28. RFC 2616:
    the internets
    Cache
    origin server
    POST/PUT/DELETE/etc.
    Invalidations after Updates or Deletions
    Request-URI
    Content-Location
    Location

    View Slide

  29. Problem: Related Responses
    POST /articles/123/new_comment
    /newest_comments
    /articles/123/comments
    /comment_feed

    View Slide

  30. Link: rel=invalidated-by
    POST /articles/123/new_comment
    /newest_comments
    /articles/123/comments
    /comment_feed
    Link: ; rel=”invalidate
    Link: ; rel=”invalidated-by”
    Link: ; rel=”invalidated-by”

    View Slide

  31. Problem 3: Dynamic Relations
    POST /articles/123/new_comment
    /newest_comments
    /articles/123/comments
    /comment_feed
    Link: ; rel=”invalidate
    Link: ; rel=”invalidated-by”
    Link: ; rel=”invalidated-by”
    /bob/comments
    /cat/vuvuzela

    View Slide

  32. Link: rel=invalidates
    POST /articles/123/new_comment
    /newest_comments
    /articles/123/comments
    /comment_feed
    Link: ; rel=”invalidate
    Link: ; rel=”invalidated-by”
    Link: ; rel=”invalidated-by”
    /bob/comments
    /cat/vuvuzela
    Link: ; rel=”invalidates”
    Link: ; rel=”invalidates”

    View Slide

  33. Linked
    Cache
    Invalidation
    “side effect” invalidation + link relations =

    View Slide

  34. Further Out
    (“there’s still life in this thing”)
    • Cache API for invalidation
    • Revisiting of^line caching
    • Forward Cache Digests
    • Explicit Cache Key

    View Slide