You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-10Lines changed: 16 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -257,22 +257,28 @@ if _, ok := err.(*github.AcceptedError); ok {
257
257
258
258
### Conditional Requests ###
259
259
260
-
The GitHub API has good support for conditional requests which will help
261
-
prevent you from burning through your rate limit, as well as help speed up your
262
-
application. `go-github` does not handle conditional requests directly, but is
263
-
instead designed to work with a caching `http.Transport`. We recommend using
264
-
[gregjones/httpcache](https://github.com/gregjones/httpcache) for that. For example:
260
+
The GitHub REST API has good support for [conditional HTTP requests](https://docs.github.com/en/rest/using-the-rest-api/best-practices-for-using-the-rest-api?apiVersion=2022-11-28#use-conditional-requests-if-appropriate)
261
+
via the `ETag` header which will help prevent you from burning through your
262
+
rate limit, as well as help speed up your application. `go-github` does not
263
+
handle conditional requests directly, but is instead designed to work with a
264
+
caching `http.Transport`.
265
+
266
+
Typically, an [RFC 7234](https://datatracker.ietf.org/doc/html/rfc7234)
267
+
compliant HTTP cache such as [gregjones/httpcache](https://github.com/gregjones/httpcache)
268
+
is recommended, ex:
265
269
266
270
```go
267
271
import"github.com/gregjones/httpcache"
268
272
269
-
client:= github.NewClient(
270
-
httpcache.NewMemoryCacheTransport().Client()
271
-
).WithAuthToken(os.Getenv("GITHUB_TOKEN"))
273
+
client:= github.NewClient(
274
+
httpcache.NewMemoryCacheTransport().Client()
275
+
).WithAuthToken(os.Getenv("GITHUB_TOKEN"))
272
276
```
273
277
274
-
Learn more about GitHub conditional requests in
275
-
["Use conditional requests if appropriate"](https://docs.github.com/en/rest/using-the-rest-api/best-practices-for-using-the-rest-api?apiVersion=2022-11-28#use-conditional-requests-if-appropriate).
278
+
Alternatively, the [bored-engineer/github-conditional-http-transport](https://github.com/bored-engineer/github-conditional-http-transport)
279
+
package relies on (undocumented) GitHub specific cache logic and is
280
+
recommended when making requests using short-lived credentials such as a
0 commit comments