Deep Dive into HTTP Caching: cache-control, no-cache, no-store, max-age, ETag and etc.

Sdílet
Vložit
  • čas přidán 28. 06. 2024
  • Caching on the Web Explained with simple examples of how HTTP Caching works, including Proxy Caching and CDNs, and how the Cache-Control header and other headers can be used with their best practices.
    ======⚡⚡⚡======
    Get a 20% discount on Brilliant.org (to learn Science, Technology, Engineering, and Math): brilliant.sjv.io/kjVO2z
    ======⚡⚡⚡======
    🙌 Become my Patreon and get exclusive perks: / softdevdiaries
    💼 Follow me on LinkedIn and drop me a message if you'd like: / gusgadirov
    💻 Also, let's connect on GitHub: github.com/gusgad
    📚 Resources:
    How CDNs work: • System Design: Content...
    HTTP "Vary" header: www.smashingmagazine.com/2017...
    HTTP "Expires" header: developer.mozilla.org/en-US/d...
    HTTP "Pragma" header: developer.mozilla.org/en-US/d...
    Problem with timezones: • The Problem with Time ...
    🕒 Timestamps:
    (00:00) Why HTTP Caching is important?
    (02:03) Cache hits and misses
    (04:32) HTTP Caching overview
    (05:42) What is a CDN?
    (07:40) max-age
    (09:17) no-store
    (10:48) no-cache
    (11:34) must-revalidate
    (12:21) public, private
    (13:11) immutable
    (13:40) stale-while-revalidate
    (14:26) stale-if-error
    (15:51) Heuristic caching
    (17:07) If-Modified-Since
    (18:27) ETag/If-None-Match
    (19:48) Cache busting
    And don't forget to subscribe for more videos like this 😊
  • Věda a technologie

Komentáře • 50

  • @SoftwareDeveloperDiaries

    Forgot to mention the "s-maxage" directive: it also indicates how long the response is going to be fresh, but it's only specific to public caches.

  • @joachimzayana1744
    @joachimzayana1744 Před 5 dny

    Please continue making video!
    Explanation are clear, introduced at the right pace, looking forward watching the others

  • @imtiazux
    @imtiazux Před 8 dny +1

    Thank you so much. Everything are now clear like water. 👌

  • @spots2012
    @spots2012 Před 6 měsíci +3

    The key nuance about must validate, is that an http response consists of both headers and body. With a validate request, the client still needs to make a request to the server, but the server can respond with headers only saying 'yup nothing changed ' and so the body does not need to be streamed.

  • @shivanshagarwal12
    @shivanshagarwal12 Před 10 měsíci +2

    went through a lot of content none could explain as easily as you did, thanks for the great video :)

  • @nithathghm4347
    @nithathghm4347 Před 11 měsíci

    Thanks! Really nice way to explain concepts 🙂

  • @akashagarwal6390
    @akashagarwal6390 Před 10 měsíci

    awesome video, really liked the in-depth details, no bullshit.

  • @tech3425
    @tech3425 Před 3 měsíci +1

    Great vid. Still confused between must-revalidate and stale-while-revalidate

  • @slickchick8292
    @slickchick8292 Před 9 měsíci

    This was so very helpful, thank you very much!

  • @quannguyenhong6300
    @quannguyenhong6300 Před 5 měsíci

    Thanks for the clear and concise video !

  • @rimagerhard5047
    @rimagerhard5047 Před rokem

    Thanks! Very nicely explained.

  • @panzerdp
    @panzerdp Před 9 měsíci

    A big THANK YOU!

  • @Pranavk-tc5sc
    @Pranavk-tc5sc Před 10 měsíci

    thanks for the content✌

  • @aamiramin6112
    @aamiramin6112 Před rokem

    So Informative. Thanks for sharing

  • @sayehghaderi9455
    @sayehghaderi9455 Před rokem

    Awesome!

  • @mahdibeldjoudi3269
    @mahdibeldjoudi3269 Před 11 měsíci +1

    This video is underrated

  • @shaheenns3113
    @shaheenns3113 Před rokem +4

    The no-cache response directive indicates that the response can be stored in caches, but the response must be validated with the origin server before each reuse, even when the cache is disconnected from the origin server.
    It goes to the server only for validaiton right ?

  • @laurassalias630
    @laurassalias630 Před rokem

    Nice!

  • @fellainthewagon7166
    @fellainthewagon7166 Před rokem +1

    today i god this question on interview but no answered. Now I know a bit more about caching via http header, thanks!

  • @Teleschmiede
    @Teleschmiede Před rokem

    Happy hello from Berlin-Spandau.

  • @gerogoya332
    @gerogoya332 Před rokem

    Great content!
    I'm doing automation and have to check (by API) if an image has changed after selecting and saving a new one.
    I store the image etag before updating the image and then I check if the etag is the same.
    Is etag reliable for the purpose?
    Thank you so much, I'm new suscriber.

    • @SoftwareDeveloperDiaries
      @SoftwareDeveloperDiaries  Před rokem

      Thanks mate! Interesting question. Since ETags are primarily about network caching, I would rather go for a more reliable way in case if you're using a database, meaning storing some kind of an image ID in the database that you can distinquish it by. If not, ETag should be enough, since a new one is created for each new resource.

  • @ihorbilobran4690
    @ihorbilobran4690 Před rokem

    Thank you, man!

    • @SoftwareDeveloperDiaries
      @SoftwareDeveloperDiaries  Před rokem

      Thanks for watching, buddy!

    • @ihorbilobran4690
      @ihorbilobran4690 Před rokem

      @@SoftwareDeveloperDiaries Great and simple explanation. Before I found your video, I was reading HTTP caching MDN docs (and I understood nothing from that)

    • @SoftwareDeveloperDiaries
      @SoftwareDeveloperDiaries  Před rokem

      @@ihorbilobran4690 those look very well structured but still hard to understand, you're right :D

  • @Sriram156
    @Sriram156 Před 7 měsíci

    Would be nice if you add the nginx configs for the various items discussed in the video. :)

  • @arknitosh
    @arknitosh Před rokem

    Very Informative video. Thanks!
    But can you please help me with the HTML code or .htaccess code? Also, How do I set the cache for 15 minutes?

    • @SoftwareDeveloperDiaries
      @SoftwareDeveloperDiaries  Před rokem +1

      Happy to help :) To set the cache for 15 minutes you can use max-age=900.
      developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#response_directives

  • @gabriel_bricage
    @gabriel_bricage Před 10 měsíci

    Hey, Great video!
    I am learning how to create websites with html css and js. I don't know anything about php. To use no-store how can I write it in my code?
    Thanks

    • @SoftwareDeveloperDiaries
      @SoftwareDeveloperDiaries  Před 10 měsíci

      Hey mate, I don't know much about PHP unfortunately. Are you using any framework?

    • @gabriel_bricage
      @gabriel_bricage Před 10 měsíci

      @@SoftwareDeveloperDiaries no I use HTML, CSS and a bit of JS. I build from scratch. But I found the solution for my question so it’s good!
      Thanks man 💪🏼

  • @TuvRaz
    @TuvRaz Před 3 měsíci +1

    I am more confused new than I was before

  • @abirsheikh5300
    @abirsheikh5300 Před 7 měsíci

    How do my browser know which server of CDN to request?

    • @SoftwareDeveloperDiaries
      @SoftwareDeveloperDiaries  Před 7 měsíci +1

      Via a DNS lookup, which will eventually lead to the closest CDN geographically. Also keep in mind that the data is cached separately for every CDN server at every location, it's not magically distributed across all servers.

    • @abirsheikh5300
      @abirsheikh5300 Před 7 měsíci

      ​@@SoftwareDeveloperDiaries thanks a lot 😊