HTTP Caching with E-Tags - (Explained by Example)

  Рет қаралды 54,776

Hussein Nasser

Hussein Nasser

Күн бұрын

HTTP ETag caching is a mechanism to validate http web cache, when server detects the tag it responds with a tiny 304 Not Modified response instead of the regular 200. in this video will explain how E-Tags work, their pros and cons and attempt to answer the question are E-Tags bad?
Video Links
High Performance WebSites
web.archive.org/web/201010032...
Reduce network bandwidth with ETag
www.infoq.com/articles/etags
Tracking without cookies using E-Tags
www.arctic.org/~dean/tracking-...
Enjoy the video!
Hussein Nasser

Пікірлер: 52
@hnasr
@hnasr 5 жыл бұрын
0:00 Whats an eTag? 4:30 Pros of eTags 7:10 Cons of eTags 12:35 Hulu use of eTags as zombie cookies
@shrishailuttagi6009
@shrishailuttagi6009 4 жыл бұрын
Etag : Its a string which represents the version of the requested resource and will change if there is the change in the response data for the same request. Pros : You can use ETag to decide which data should be used , cached data or fresh data from the server.
@ragingpahadi
@ragingpahadi 3 жыл бұрын
love your series man ! it is very real based problems which we face in real software develpment ! keep up good work
@hnasr
@hnasr 5 жыл бұрын
Question of the day have you ever used eTags? If not now that you know about them would you consider using them and why?
@fabgwada8718
@fabgwada8718 5 жыл бұрын
Thank you! Exactly the explanations I was looking for!
@hnasr
@hnasr 5 жыл бұрын
fab gwada glad I could help :)
@mavenikofficial
@mavenikofficial 3 жыл бұрын
Where does cached data return from ? In Nodejs with Express lets assume etag is enabled Then from where the cached response being used , is it stored at client side or server side in memory ?
@danielglazer123
@danielglazer123 2 жыл бұрын
@Hussein Nasser , I haven't used etags before. I am considering using it in a use case with the following details. I have a json file stored in a storage account of the cloud provider, it is the responsibility of some micro service in our k8s cluster to read and serve this json (sometime after filtering) to another type of MS in our cluster. All the replicas of the ms read the same file(something known as PVC or persistent storage claim). This enables me to read the file once, store it in memory and in all the following calls to only read the file last modification from metadata to see if I need to read the whole file again. I only want to read again if the file changed.. My question now is if this a good use case for the clients (some other MS servers) and the MSs that serve this file to use etag or LastModified maybe? I think that I can use the last modified date and hash it as etag and it will be the same in all the MSs since its the same shared file.. but I will still need to implement the etag logic in the client servers and maybe use a shared cache between those clients with the etag right? Thanks in advance for your input ;)
@imaneamouna936
@imaneamouna936 3 жыл бұрын
How can we generate an Etag for a ressource PLEASE? in order to add it into a header's request abd avoid 412 HTTP errors? Thanks!
@kritisharma8352
@kritisharma8352 2 жыл бұрын
Hi Hussein , I was using etag in my work and came across with the doubt that what if we are caching server response in CDN in middle , in this case when browser sends etag with next request[If-None-Match] then this etag will be matched with CDN cached response? or how will it directly goto server for etag matching?
@nadergalal1572
@nadergalal1572 Жыл бұрын
I have used etag by setting eTag property to true on the main web site under IIS, but when file changes, i still get the cached copy not the new one, any help with that please.
@AbhishekSHARMA-he1fd
@AbhishekSHARMA-he1fd 4 жыл бұрын
Hi Hussein, Hope you are doing well. Thank you for the last reply on Caching. I want to know why we use e-tag if we already have last modified(if modified since to check freshness of the resource) filed in http response. How e-tag's are calculated.
@hnasr
@hnasr 4 жыл бұрын
Excellent question! You use the last modified property on files such as images, text, html etc. However for dynamically generated content such as json response that doesn’t necessarily corresponds to a physical file on disk ( ( e.g. resulted from querying a database )) we use an etag which is a hash of the content could be md5 or SHA. Multiple web servers has different implementation of etags Hope that helpa
@CoolBruce100
@CoolBruce100 4 жыл бұрын
@@hnasr Referring to the first cons, for different application servers under a load balancer, if they are configured to use the same algorithm to generate Etag, then it will not be an issue. Is this understanding correct?
@virajmota8527
@virajmota8527 4 жыл бұрын
Thanks for explaining ! I have one query -as u said user first req n server will assign e-tag to him for that particular request. - wht if other user request same url as first. Will he get same etag which user 1 got or different? - what is rule of middleware thus middleware leads to cache poisoning even when E-Tag header is using ?
@hnasr
@hnasr 4 жыл бұрын
Great questions! That depends on the implementations of the web server some web server generate unique e-tag per document (resource) regardless of the source ip in that case etag will be the same for all users which isn’t a big deal. Some use the source ip or some other mechanisms to generate the etag in that case it will be unique per user. Cache poisoning and HTTP smuggling is a problem with proxies and middle way I talked about them in this video little bit kzfaq.info/get/bejne/npeEjdOIx9vHmmQ.html In a nutshell if an attacker can somehow cache a bad website with etag X in the proxy cache layer then a normal user tries to visit a legitimate website that somehow also generate etag X then the user can be served the poisoned cache with bad website.. But its not something simple to get into its tricky Hope that helps
@sarcaastech
@sarcaastech Жыл бұрын
Done ✔️ thanks for knowledge 🙏
@jeno427
@jeno427 5 жыл бұрын
I will definitely use them. Looks like they are implemented by default in Nginx.
@hnasr
@hnasr 5 жыл бұрын
Jeno yeah most web servers implement them, you just need to make sure you get the same e-tag for the same resource in different stateless web servers. Would be good experiment 🧪 thanks for your comment!
@troooooper100
@troooooper100 3 жыл бұрын
so what if you visit a different page, then etag tracking doesn't work?
@mrqreeny
@mrqreeny 4 жыл бұрын
Now, if ETags are used as zombie cookies, it will never return an update of the requested page right? Or is the response be configured on the server to send the content for every request regardless of the ETag?
@hnasr
@hnasr 4 жыл бұрын
NM vd S excellent question and yes the server code is modified to use eTags as an identity and always sends a fake 304 not modified to the client along a request to recreate cookies if it doesn’t exist. Remember the server is using the eTag only to recreate the cookie. Once the cookie is created we use the cookie as an identity. If the cookie was deleted, the etag is sent and we use that to recreate the cookie. Here is an example of implementation zombie cookie with etags that i did a while back How Un-deletable Zombie Cookies work (with implementation example) kzfaq.info/get/bejne/otdmjcyerc6Rmmg.html
@enhboldotgonbaatar248
@enhboldotgonbaatar248 5 жыл бұрын
Great video
@thecyrusj13
@thecyrusj13 4 жыл бұрын
I don't know if you have ever used AWS CloudFront but if you have is there anyway to incorporate E-Tags into this service and if so is there any advantage?
@hnasr
@hnasr 4 жыл бұрын
thecyrusj13 Hey didnt use AWS Cloud front, but e-tags comes pretty much by default with every web server. Its just a built in feature. You can tell by checking the responses from your requests (in chrome for example) and see if e-tags headers are coming back As for the advantage, it really lower the bandwidth for your consumers and prevent any unnecessary computations on the backend. Thats only true for GET requests though. Hope that helps!
@nityadeepika1967
@nityadeepika1967 2 жыл бұрын
I was hoping the video to be on-point. :)
@DanielLewisSEO
@DanielLewisSEO 3 жыл бұрын
I get why to use them and I want to I cant seem to figure out how to generate them. Did I miss that part?
@hnasr
@hnasr 3 жыл бұрын
Daniel Lewis if you use web framework like express you can return the etag by setting the header in the response I am not sure you have low level control over etags headers with normal webservers like apache or tomcat
@DanielLewisSEO
@DanielLewisSEO 3 жыл бұрын
@@hnasr Sorry that was mostly out of my depth, I have a whm with cpanels I have built an AMP site going through the lighthouse report and gtmetrix to try and make it as fast as possible. Its frustrating to me that I have some wordpress sites that are showing as faster than the amp site. Anyway one of the things it said was to use etags and I get the idea, I just do not know how to generate the code so it knows if the resource has changed.
@leo-rq2ei
@leo-rq2ei 5 жыл бұрын
Thank youuuu
@Ali_Alhajji
@Ali_Alhajji 4 жыл бұрын
Why can't we use the page/resource hash as a tag? We will not have to deal with the load balancer problem. And we will eliminate the zombie cookies problem too.
@hnasr
@hnasr 4 жыл бұрын
You can, some server implementation does that actually. However some implementation uses some other methods to make sure hashing the content everytime doesn’t harm the performance specially if the resource is big or the resource is sitting in a database somewhere and hitting it is costly
@subhamprasad1373
@subhamprasad1373 2 жыл бұрын
please make a video, how http file upload works.
@UsmanAfz
@UsmanAfz 4 жыл бұрын
Hussein would this be the same be the of CDNs?
@hnasr
@hnasr 4 жыл бұрын
Usman Afzal yes this applies to any web server that supports e-tags and CDNa are nothing but web servers.
@RaajAhuja
@RaajAhuja 3 жыл бұрын
What is the alternative of eTag?
@hnasr
@hnasr 3 жыл бұрын
building your own client side caching
@yadusolparterre
@yadusolparterre 3 жыл бұрын
But if Hulu keeps sending you the same e-tag, then the client never sees the new index.html, no?
@hnasr
@hnasr 3 жыл бұрын
Correct but they don’t care really if client got a slightly out of date content.
@yadusolparterre
@yadusolparterre 3 жыл бұрын
@@hnasr thanks !
@emmanuelidun7973
@emmanuelidun7973 3 жыл бұрын
Where's the link to the concurrency?
@hnasr
@hnasr 3 жыл бұрын
kzfaq.info/get/bejne/h6l7jZaHv56bgaM.html
@Andrei-ds8qv
@Andrei-ds8qv 4 жыл бұрын
why theher is that drum sound in the background? Tip: you can filter the unwanted sound by sampleling some seconds of video where you dont't say anything and then filtering out those frequencies
@Andrei-ds8qv
@Andrei-ds8qv 4 жыл бұрын
ah ok...that was music...but boy it was anoyting....ahhahaha
@hnasr
@hnasr 4 жыл бұрын
Yeah I know that was one bad experiment I no longer use background music. Learned my lesson 😂
@ca7986
@ca7986 4 жыл бұрын
❤️
@sfsf285
@sfsf285 2 жыл бұрын
Thats for the video, I dont understand most of this etag crap, arent they like a hashed version of the response? For example if an http response object will return with json, then the server will get an etag number out of that? So each time the server needs to check if the etag is a match it has to reload the data to check? Or its cached somewhere or what the fuck?
@TheMrYogesh
@TheMrYogesh 3 жыл бұрын
This video could have been just 6 mins instead of 16 mins
@ylmaznaciaslan9508
@ylmaznaciaslan9508 2 жыл бұрын
Thanks for the explanation. But this video could have been much shorter. You basically say the same things over and over again
@SamSam-eu8vx
@SamSam-eu8vx Жыл бұрын
Man your videos are ok but you talk too much! you just make it too long for something can be explained in much shorter time.
Stateful vs Stateless Applications (Explained by Example)
14:44
Hussein Nasser
Рет қаралды 196 М.
Deep Dive into HTTP Caching: cache-control, no-cache, no-store, max-age, ETag and etc.
21:28
Smart Sigma Kid #funny #sigma #comedy
00:19
CRAZY GREAPA
Рет қаралды 23 МЛН
I’m just a kid 🥹🥰 LeoNata family #shorts
00:12
LeoNata Family
Рет қаралды 17 МЛН
Always be more smart #shorts
00:32
Jin and Hattie
Рет қаралды 34 МЛН
Everything you need to know about HTTP Caching
13:33
the roadmap
Рет қаралды 150 М.
Web Server Concepts and Examples
19:40
WebConcepts
Рет қаралды 230 М.
Optimistic Concurrency in an HTTP API with ETags & Hypermedia
11:46
Remix Run - Introduction to HTTP Caching
17:54
Remix
Рет қаралды 24 М.
Why .NET's memory cache is kinda flawed
14:13
Nick Chapsas
Рет қаралды 55 М.
Difference between cookies, session and tokens
11:53
Valentin Despa
Рет қаралды 590 М.
When to use HTTP GET vs POST?
21:10
Hussein Nasser
Рет қаралды 29 М.
Собери ПК и Получи 10,000₽
1:00
build monsters
Рет қаралды 1,5 МЛН
Main filter..
0:15
CikoYt
Рет қаралды 11 МЛН
Cadiz smart lock official account unlocks the aesthetics of returning home
0:30
Samsung S24 Ultra professional shooting kit #shorts
0:12
Photographer Army
Рет қаралды 32 МЛН
YOTAPHONE 2 - СПУСТЯ 10 ЛЕТ
15:13
ЗЕ МАККЕРС
Рет қаралды 95 М.