tag:blogger.com,1999:blog-9941980.post112775387208652251..comments2023-11-05T11:47:51.059+02:00Comments on Software Development: Server side: ETag VS Cache-Control max-age=xxxx or Expiration VS ValidationVhttp://www.blogger.com/profile/07384298883237115882noreply@blogger.comBlogger11125tag:blogger.com,1999:blog-9941980.post-22875556788842085832010-10-24T11:51:37.288+03:002010-10-24T11:51:37.288+03:00Nice explanation. Just what I was looking for.
M...Nice explanation. Just what I was looking for. <br /><br />Many thanks,irfanhttps://www.blogger.com/profile/11601582823200426073noreply@blogger.comtag:blogger.com,1999:blog-9941980.post-56042030771978058812010-02-26T01:43:45.764+02:002010-02-26T01:43:45.764+02:00hi people. I'm actually into shoes and I was ...hi people. I'm actually into shoes and I was looking as far as something that singular brand. The prices seeking the sneakers were all over 240 bucks on every site. But definitively I set this locate selling them for half price. I exceptionally like these [url=http://www.shoesempire.com]prada sneakers[/url]. I will probably buy those. what can you say about it?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-9941980.post-50863866688799784962009-05-18T10:48:00.000+03:002009-05-18T10:48:00.000+03:00Yes, I missed the point about reducing response si...Yes, I missed the point about reducing response size.<br /><br />Now I see that these two cache methods can be used together. And that they complement each other.<br /><br />Thank you for your effort :)Vhttps://www.blogger.com/profile/07384298883237115882noreply@blogger.comtag:blogger.com,1999:blog-9941980.post-53684412785475891172009-05-18T05:07:00.000+03:002009-05-18T05:07:00.000+03:00Vadym,
You point out that, after max-age expires,...Vadym,<br /><br />You point out that, after max-age expires, the client sends out a new request and the server issues a response. As I understood your point, you were saying that, if a max-age was included in the response, it would take precedence, and therefore it would be useless to use both; you should use one or the other.<br /><br />The point that you're overlooking is that not all responses are created equal.<br /><br />If, when the client first downloads the resource, the server only sends a max-age, but no ETag, the client will re-download the WHOLE RESOURCE in subsequent requests where the max-age has expired.<br /><br />However, if both an ETag and a max-age are included in the original response, the client will run a conditional request upon the max-age expiring. This means that, instead requesting the resource all over again, the client includes the original ETag with the request and tells the server to only send the new resource if the ETag has changed.<br /><br />So, like I was saying earlier, max-age sets an Expires time on the conten, while ETags can be used to see if, after the max-age is up, the content is still valid and no re-downloading is necessary.<br /><br />In case I'm still explaining myself poorly, I've included a few quotes from the <A HREF="http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.3.3" REL="nofollow">official w3.org page on the HTTP 1.1 spec</A>.<br /><br />From the introductory paragraph, explaining what I was trying to say about expiration vs. validation: "The goal of caching in HTTP/1.1 is to eliminate the need to send requests in many cases, and to eliminate the need to send full responses in many other cases. The former reduces the number of network round-trips required for many operations; we use an "expiration" mechanism for this purpose (see section 13.2). The latter reduces network bandwidth requirements; we use a "validation" mechanism for this purpose (see section 13.3). "<br /><br />And, from the respective paragraphs on max-age and ETags. <br /><br />Of max-age:<br />"The primary mechanism for avoiding requests is for an origin server to provide an explicit expiration time in the future [so that] a cache can return a fresh response without first contacting the server."<br /><br />Of ETag:<br />"When a cache has a stale entry that it would like to use as a response... it first has to check with the origin server to see if its cached entry is still usable. We call this "validating" the cache entry. Since we do not want to have to pay the overhead of retransmitting the full response if the cached entry is good, and we do not want to pay the overhead of an extra round trip if the cached entry is invalid, the HTTP/1.1 protocol supports the use of conditional methods."Unknownhttps://www.blogger.com/profile/13091562443076071593noreply@blogger.comtag:blogger.com,1999:blog-9941980.post-16388105155869692722009-05-13T09:48:00.000+03:002009-05-13T09:48:00.000+03:00ETag is a response header. Client has to do the re...ETag is a response header. Client has to do the request to get new etag (to detect resource change). <br /><br />While caching mechanism (max-age) implies that no network activity is made by the client because it believes that content is fresh. <br /><br />When max-age expires client sends request and receives response. That response may contain max-age and etag. But if it contains both: max-age has the precedence (client will not do any requests fox max-age: x seconds). If client is not making requests it has no ability to validate etag.<br /><br />That is why max-age and etag mechanisms should be uses separately.Vhttps://www.blogger.com/profile/07384298883237115882noreply@blogger.comtag:blogger.com,1999:blog-9941980.post-73162718748768344002009-05-13T05:58:00.000+03:002009-05-13T05:58:00.000+03:00When I said max-age and Etags were meant to be use...When I said max-age and Etags were meant to be used together, i meant that you're supposed to use both of them, not that you could somehow include a max-age in your Etag header or vice-versa.<br /><br />My point was that you can't compare the Cache-Control:max-age = x header and the Etag header because they serve different purposes and, for optimal caching, you should use both. <br /><br />After rereading my comment, I realize it was pretty unclear. Here's my understanding of how the process works:<br /><br />Cache-Control:max-age = x tells the client that the content is GUARANTEED fresh for x seconds (that's why the client doesn't make any requests to the server before the max-age time is up-- like you said in your post). <br /><br />Once the x seconds have elapsed, the content is NO LONGER GUARANTEED FRESH, BUT MAY STILL BE. Therefore, the next time you request the cached element, the ETag is invoked for validation (i.e. rather than asking for the content again, the client asks for the new ETag to see if the content has changed. If the ETag has changed, it requests the new content, but otherwise it doesn't, saving time.)<br /><br />If that's unclear, here's a much more-detailed, better-written <A HREF="http://www.mnot.net/cache_docs/" REL="nofollow">description of the caching process</A>Unknownhttps://www.blogger.com/profile/13091562443076071593noreply@blogger.comtag:blogger.com,1999:blog-9941980.post-63251847729318275222009-05-12T11:12:00.000+03:002009-05-12T11:12:00.000+03:00Etag and max-age are two different mechanisms. Acc...Etag and max-age are two different mechanisms. According to <A HREF="http://tools.ietf.org/html/rfc2616#section-14.19" REL="nofollow">this</A>, max-age header cannot be used.Vhttps://www.blogger.com/profile/07384298883237115882noreply@blogger.comtag:blogger.com,1999:blog-9941980.post-48929404910833307182009-05-12T10:47:00.000+03:002009-05-12T10:47:00.000+03:00I think you have things a little off, but I could ...I think you have things a little off, but I could be wrong.<br /><br />From my understanding of caching, max-age and etags are supposed to be used together. Up until the max-age, like you said, the client doesn't request any new material. But, after the max-age expires, the client will send an etag (which the server should have sent with the original file) for validation against the current etag on the server. If the two match, the client knows the data is still fresh, so it can continue to use it and it will update reset the max-age.Unknownhttps://www.blogger.com/profile/13091562443076071593noreply@blogger.comtag:blogger.com,1999:blog-9941980.post-11164159414903558702008-08-21T14:45:00.000+03:002008-08-21T14:45:00.000+03:00Yes, you're right. Thanks, I'll correct that ASAPYes, you're right. Thanks, I'll correct that ASAPVhttps://www.blogger.com/profile/07384298883237115882noreply@blogger.comtag:blogger.com,1999:blog-9941980.post-9469818738977166872008-08-21T12:13:00.000+03:002008-08-21T12:13:00.000+03:00A little typo I noticed. As I understand it, the m...A little typo I noticed. As I understand it, the max-age directive is in seconds. 60[seconds] * 60[minutes] = 3600.<BR/><BR/>So 1 hour would be max-age = 3600Unknownhttps://www.blogger.com/profile/07244979258788263681noreply@blogger.comtag:blogger.com,1999:blog-9941980.post-16992474024354355292008-06-17T11:28:00.000+03:002008-06-17T11:28:00.000+03:00Thaks. this was helpful.Thaks. this was helpful.Anonymousnoreply@blogger.com