+
Skip to content

Unit test needed to prevent #14 regression #45

Closed
@runemadsen

Description

@runemadsen

Hi there

Awesome library. I have one question though:

It seems like you're appending random query strings to the end of every API call, probably in order to make sure you get a non-cached response on every call.

However, the Gihub API implements a pretty smart HTTP caching, that is being ignored with this library. For people using it, it means that the rate-limit will get used much faster, and apps will try to reload content that is not updated.

Here's an example of what I mean:

/* Using JQuery
____________________________________________ */

$.ajax({
  url:"https://user:pass@api.github.com/repos/user/repo",
  success: function(data) { console.log(data) }
});
// --> response 200 with content

$.ajax({
  url:"https://user:pass@api.github.com/repos/user/repo",
  success: function(data) { console.log(data) }
});
// --> if called again within 60 seconds this call will never be made, 
//      as the Github API has HTTP cache of 60 seconds. If after 
//      60 seconds and data is not updated, it returns an empty 
//      304 not modified, which is much faster

/* Using github.js
____________________________________________ */

var github = new Github({
  username: "user",
  password: "pass",
  auth: "basic"
});
var repo = github.getRepo(user, repo);

repo.show(function(err, repo) { console.log(repo) });
// --> response 200 with content

repo.show(function(err, repo) { console.log(repo) });
// --> response 200 with content, no caching

repo.show(function(err, repo) { console.log(repo) });
// --> response 200 with content, no caching

I saw that you have "implemented smart caching" in a commit, so I'm not sure exactly what's going on. How is this library caching stuff?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载