Which is more reliable for Github API Conditional Requests, ETag or Last-Modified?

The Github API specifies two headers that can be used in Conditional Requests, Last-Modified and ETag. Which is the more reliable when querying the API?

For context: when using the api endpoint GET /repos/:owner/:repo/git/trees/:sha on each subdir of a large repo, every response contains the same last-modified value (even though the repo on github shows different authored dates) while the etag value for each is different. I'm wondering if the ETag is a more granular representation of repo content state change (for caching purposes).

Answers


Reading "ETags: a pretty sweet feature of HTTP 1.1", it says:

"ETags allow dynamic content to be cached using an app-specific "opaque token""

An ETag, or entity tag, is an opaque token that identifies a version of the component served by a particular URL. The token can be anything enclosed in quotes; often it's an md5 hash of the content, or the content's VCS version number.

If the content of the answer is the same, the ETag should be identical everytime.

I just tested it with https://api.github.com/repos/VonC/gopanic/git/trees/master, and indeed its ETag remains W/"34a03ea1d4dc0b5d533ecf8d36492879" even when called repeatedly.

But should I get the tree for each subfolder, then the ETag would vary because it represents a signature of the different response content.

The advantage of ETag is that it doesn't depend on a date (whose clock might vary for diverse reason), but on the content of the answer: if unchanged, it means the content sent is still the same than the one sent before.


Need Your Help

Finding maximum distance between (x,y) coordinates

java c++ algorithm distance

Im trying to calculate the maximum manhattan distance of a large 2D input , the inputs are consisting of (x, y)s and what I want to do is to calculate the maximum distance between those coordinates...

Loading ListView and ImageList while using a backgroundWorker

c# listview backgroundworker imagelist

Loading the imagelist and the listview obviously causes the UI to hang a little. So I'd like to load the UI and let the user know we are working on things and let the backgroundWorker do it's thin...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.