{"id":23682903,"url":"https://github.com/johejo/cachehandler","last_synced_at":"2025-09-02T11:31:19.436Z","repository":{"id":37017788,"uuid":"340450950","full_name":"johejo/cachehandler","owner":"johejo","description":"Package cachehandler provides net/http middleware that caches HTTP responses.","archived":false,"fork":false,"pushed_at":"2022-08-19T09:05:20.000Z","size":15,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-06-21T11:01:22.474Z","etag":null,"topics":["cache","caching","go","golang","handler","http","middleware"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johejo.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":"2021-02-19T18:06:08.000Z","updated_at":"2022-06-18T21:33:45.000Z","dependencies_parsed_at":"2022-08-18T22:00:52.412Z","dependency_job_id":null,"html_url":"https://github.com/johejo/cachehandler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johejo%2Fcachehandler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johejo%2Fcachehandler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johejo%2Fcachehandler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johejo%2Fcachehandler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johejo","download_url":"https://codeload.github.com/johejo/cachehandler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231780340,"owners_count":18425542,"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","caching","go","golang","handler","http","middleware"],"created_at":"2024-12-29T19:59:22.574Z","updated_at":"2024-12-29T19:59:23.302Z","avatar_url":"https://github.com/johejo.png","language":"Go","readme":"# cachehandler\n\nPackage cachehandler provides net/http middleware that caches HTTP responses.\n\nInspired by go-chi/stampede. https://github.com/go-chi/stampede\n\nThe HTTP response is stored in the cache and calls to handlers with the same key are merged.\n\n[![ci](https://github.com/johejo/cachehandler/workflows/ci/badge.svg?branch=main)](https://github.com/johejo/cachehandler/actions?query=workflow%3Aci)\n[![Go Reference](https://pkg.go.dev/badge/github.com/johejo/cachehandler.svg)](https://pkg.go.dev/github.com/johejo/cachehandler)\n[![codecov](https://codecov.io/gh/johejo/cachehandler/branch/main/graph/badge.svg)](https://codecov.io/gh/johejo/cachehandler)\n[![Go Report Card](https://goreportcard.com/badge/github.com/johejo/cachehandler)](https://goreportcard.com/report/github.com/johejo/cachehandler)\n\n## Example\n\n```go\npackage cachehandler_test\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"net/http/httptest\"\n\t\"time\"\n\n\t\"github.com/johejo/cachehandler\"\n)\n\nfunc Example() {\n\tmux := http.NewServeMux()\n\tm := cachehandler.NewMiddleware(1000, 1*time.Hour, cachehandler.BasicKeyFunc())\n\tvar called int\n\tmux.Handle(\"/\", m.Wrap(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {\n\t\tcalled++\n\t})))\n\n\tts := httptest.NewServer(mux)\n\tdefer ts.Close()\n\n\tresp1, err := http.Get(ts.URL + \"/foo\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp1.Body.Close()\n\n\tresp2, err := http.Get(ts.URL + \"/foo\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp2.Body.Close()\n\n\tfmt.Printf(\"called %d\", called)\n\n\t// Output:\n\t// called 1\n}\n```\n\n## License\n\nMIT\n\n## Author\n\nMitsuo Heijo\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohejo%2Fcachehandler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohejo%2Fcachehandler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohejo%2Fcachehandler/lists"}