{"id":15673844,"url":"https://github.com/lmammino/guzzle-fs-cache-middleware","last_synced_at":"2025-08-01T06:32:52.977Z","repository":{"id":62518382,"uuid":"251672078","full_name":"lmammino/guzzle-fs-cache-middleware","owner":"lmammino","description":"A simple FS backed guzzle cache file middleware compatible with php 5.6","archived":false,"fork":false,"pushed_at":"2020-03-31T17:47:16.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T05:44:19.443Z","etag":null,"topics":["cache","filesystem","guzzle","http"],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/lmammino.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":"2020-03-31T16:59:23.000Z","updated_at":"2020-03-31T17:53:46.000Z","dependencies_parsed_at":"2022-11-02T13:31:26.804Z","dependency_job_id":null,"html_url":"https://github.com/lmammino/guzzle-fs-cache-middleware","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/lmammino/guzzle-fs-cache-middleware","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmammino%2Fguzzle-fs-cache-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmammino%2Fguzzle-fs-cache-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmammino%2Fguzzle-fs-cache-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmammino%2Fguzzle-fs-cache-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lmammino","download_url":"https://codeload.github.com/lmammino/guzzle-fs-cache-middleware/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lmammino%2Fguzzle-fs-cache-middleware/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268181042,"owners_count":24209143,"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","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","filesystem","guzzle","http"],"created_at":"2024-10-03T15:42:30.100Z","updated_at":"2025-08-01T06:32:52.913Z","avatar_url":"https://github.com/lmammino.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# guzzle-fs-cache-middleware\n\nA minimalist and opinionated Cache Middleware for Guzzle that uses the FileSystem as backend (compatible with PHP 5.6+).\n\n## Install\n\nUsing composer:\n\n```bash\ncomposer require lmammino/guzzle-fs-cache-middleware\n```\n\n## Usage\n\nCreate an instance of `LM\\Guzzle\\FS\\CacheMiddleware` and add it to your middleware stack:\n\n```php\nrequire_once __DIR__.'/vendor/autoload.php';\n\nuse GuzzleHttp\\HandlerStack;\nuse GuzzleHttp\\Handler\\CurlHandler;\nuse GuzzleHttp\\Client;\nuse LM\\Guzzle\\FS\\CacheMiddleware;\n\n$cacheDir = __DIR__.'/cache/';\n$namespace = 'api_client';\n$ttl = 60;\n$cacheMiddleware = new CacheMiddleware($cacheDir, $namespace, $ttl);\n\n$stack = new HandlerStack();\n$stack-\u003esetHandler(new CurlHandler());\n$stack-\u003epush($cacheMiddleware);\n$client = new Client(['handler' =\u003e $stack]);\n\n$res = $client-\u003erequest('GET', $argv[1]);\n$headers = $res-\u003egetHeaders();\nforeach ($headers as  $k =\u003e $h) {\n    foreach ($h as $v) {\n        echo $k . \": \" . $v . \"\\n\";\n    }\n}\necho \"\\n\\n\" . $res-\u003egetBody()-\u003e__toString() . \"\\n\\n\";\n```\n\n`CacheMiddleware` accepts a cache directory, an optional namespace (defaults to `default`) and an optiona ttl in seconds (defaults to `60`).\n\n**Note**: this middleware will always respect the TTL you provide and will ignore any HTTP cache header returned as response. This is by design. Use this middleware only if you want to enforce cache or for micro-caching scenarios (e.g. very expensive and frequent API calls).\n\n## Contributing\n\nEveryone is very welcome to contribute to this project.\nYou can contribute just by submitting bugs or suggesting improvements by\n[opening an issue on GitHub](https://github.com/lmammino/guzzle-fs-cache-middleware/issues).\n\n\n## License\n\nLicensed under [MIT License](LICENSE). © Luciano Mammino.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flmammino%2Fguzzle-fs-cache-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flmammino%2Fguzzle-fs-cache-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flmammino%2Fguzzle-fs-cache-middleware/lists"}