{"id":19492343,"url":"https://github.com/hinha/httpcache","last_synced_at":"2026-04-20T14:07:37.482Z","repository":{"id":57712759,"uuid":"514506946","full_name":"hinha/httpcache","owner":"hinha","description":"Golang HTTP Client Cache","archived":false,"fork":false,"pushed_at":"2022-07-17T14:08:30.000Z","size":38,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-08T09:11:04.651Z","etag":null,"topics":["cache","golang","http","http-client","redis"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hinha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-16T07:14:53.000Z","updated_at":"2023-12-25T09:06:06.000Z","dependencies_parsed_at":"2022-09-26T21:30:47.599Z","dependency_job_id":null,"html_url":"https://github.com/hinha/httpcache","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hinha%2Fhttpcache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hinha%2Fhttpcache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hinha%2Fhttpcache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hinha%2Fhttpcache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hinha","download_url":"https://codeload.github.com/hinha/httpcache/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240738118,"owners_count":19849549,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","golang","http","http-client","redis"],"created_at":"2024-11-10T21:20:29.559Z","updated_at":"2025-11-18T14:34:45.981Z","avatar_url":"https://github.com/hinha.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Inject-able HTTP cache in Golang\n Just inject the cache to the HTTP client, this will integrate with cache (Redis)\n\n## Quickstart\n\nMake sure you have Go installed ([download](https://golang.org/dl/)). Version `1.16` or higher is required.\n\nInitialize your project by creating a folder and then running `go mod init github.com/your/repo` ([learn more](https://blog.golang.org/using-go-modules)) inside the folder. Then install httpcache library with the [`go get`](https://golang.org/cmd/go/#hdr-Add_dependencies_to_current_module_and_install_them) command:\n\n```sh\ngo get -u github.com/hinha/httpcache\n```\n\n## Example\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"net/http\"\n\t\"time\"\n\n\t\"github.com/hinha/httpcache\"\n\t\"github.com/hinha/httpcache/cache\"\n)\n\nvar (\n\turl   = \"https://google.com\"\n\ttoken = \"toke\"\n)\n\nfunc main() {\n\tclient := \u0026http.Client{}\n\t// when webStatic is true can only be used static web ex: google.com\n\t// cause need cache-control\n\twebStatic := true\n\t_ = cache.NewRedisCache(client, \u0026httpcache.RedisCacheOptions{\n\t\tAddr: \"localhost:6379\",\n\t}, time.Second*time.Duration(60))\n\n\theader := http.Header{}\n\t// header.Set(\"Authorization\", token) // if need header\n\n\tfor i := 0; i \u003c 10; i++ {\n\t\treq, err := http.NewRequest(\"GET\", url, nil)\n\t\tif err != nil {\n\t\t\tlog.Fatal((err))\n\t\t}\n\t\treq.Header = header\n\n\t\tres, err := client.Do(req)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tfmt.Println(\"Status Code\", res.StatusCode)\n\t}\n}\n```\n\n## Inspirations and Thanks\n- [pquerna/cachecontrol](https://github.com/pquerna/cachecontrol) for the Cache-Header Extraction","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhinha%2Fhttpcache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhinha%2Fhttpcache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhinha%2Fhttpcache/lists"}