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 full-size slide

  2. At First Sight:
    The Honeymoon

    View full-size slide

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

    View full-size slide

  4. Relationship Trouble

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  7. Mozilla: 100 pages

    View full-size slide

  8. 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 full-size slide

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

    View full-size slide

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

    View full-size slide

  11. HTML5 AppCache

    View full-size slide

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

    View full-size slide

  13. Getting to know
    each other

    View full-size slide

  14. max-age / expires
    Chrome 6
    IE7

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  17. Date
    Safari 5.0.2
    IE (any)

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  21. stale-while-revalidate
    cache

    View full-size slide

  22. stale-if-error

    View full-size slide

  23. Cache Invalidation

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  26. 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 full-size slide

  27. 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 full-size slide

  28. 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 full-size slide

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

    View full-size slide

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

    View full-size slide