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

Demystifying HTTP Headers for a Better Web @ SpaceCityJS

Demystifying HTTP Headers for a Better Web @ SpaceCityJS

Ever wonder exactly what combination of Cache-Control, Last-Modified, Expires, ETag, Vary, and Pragma headers will keep your content cached by browsers just long enough? And what exactly is a HTTP 304 anyway? In this talk, you’ll learn the history behind the available HTTP caching headers, what their values mean, and how browsers and proxies react. You’ll learn the best practices on client cache invalidation, the benefits of sending a Not Modified response, and briefly talk about the changes in HTTP 2.0 (SPDY) around caching — and then you’ll put your new-found header skills to the test!

Andrew Dunkman

March 28, 2015
Tweet

More Decks by Andrew Dunkman

Other Decks in Technology

Transcript

  1. Demystifying HTTP Headers
    for a Better Web
    Andrew: @adunkman

    View Slide

  2. http caching

    View Slide

  3. shared caches

    View Slide

  4. Expires, Vary
    Cache-Control
    Conditional Requests
    The Future of Caching

    View Slide

  5. Expires, Vary
    Cache-Control
    Conditional Requests
    The Future of Caching

    View Slide

  6. Wed, 14 May 2014 22:36:20 GMT

    View Slide

  7. Vary: User-Agent

    View Slide

  8. Vary: Accept-Encoding

    View Slide

  9. Expires, Vary
    Cache-Control
    Conditional Requests
    The Future of Caching

    View Slide

  10. Expires, Vary
    Cache-Control
    Conditional Requests
    The Future of Caching

    View Slide

  11. no-cache
    no-store
    no-transform
    max-age
    s-maxage
    must-revalidate
    proxy-revalidate
    max-stale
    public
    private

    View Slide

  12. max-age
    must-revalidate
    private
    public

    View Slide

  13. Expires, Vary
    Cache-Control
    Conditional Requests
    The Future of Caching

    View Slide

  14. Expires, Vary
    Cache-Control
    Conditional Requests
    The Future of Caching

    View Slide

  15. Last-Modified
    If-Modified-Since

    View Slide

  16. Etag
    If-None-Match

    View Slide

  17. Expires, Vary
    Cache-Control
    Conditional Requests
    The Future of Caching

    View Slide

  18. Expires, Vary
    Cache-Control
    Conditional Requests
    The Future of Caching

    View Slide


  19. View Slide

  20. Link: ; rel=prefetch

    View Slide


  21. View Slide

  22. Link: ; rel=subresource

    View Slide

  23. SPDY

    View Slide

  24. mod_spdy

    View Slide

  25. X-Associated-Content:
    "full-url":

    View Slide

  26. Expires, Vary
    Cache-Control
    Conditional Requests
    The Future of Caching

    View Slide

  27. mnot.net/cache_docs
    adunkman/http-cache-demo

    View Slide

  28. Thank you!
    Andrew: @adunkman

    View Slide