{"id":21586044,"url":"https://github.com/magiclen/nginx-cache-purge","last_synced_at":"2025-10-09T10:34:41.238Z","repository":{"id":57644923,"uuid":"268931890","full_name":"magiclen/nginx-cache-purge","owner":"magiclen","description":"An alternative way to do `proxy_cache_purge` or `fastcgi_cache_purge` for Nginx.","archived":false,"fork":false,"pushed_at":"2025-08-12T01:16:14.000Z","size":50,"stargazers_count":58,"open_issues_count":5,"forks_count":12,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-09-07T13:48:15.140Z","etag":null,"topics":["cache","cli","nginx","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/magiclen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-02T23:44:03.000Z","updated_at":"2025-08-12T06:09:26.000Z","dependencies_parsed_at":"2023-11-15T03:25:04.437Z","dependency_job_id":"b4f8b79d-5661-4a11-9e3b-a2ba3e5556be","html_url":"https://github.com/magiclen/nginx-cache-purge","commit_stats":{"total_commits":19,"total_committers":1,"mean_commits":19.0,"dds":0.0,"last_synced_commit":"d0cec8ac59d432453ae360c653ec2ca5adca6b42"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/magiclen/nginx-cache-purge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fnginx-cache-purge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fnginx-cache-purge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fnginx-cache-purge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fnginx-cache-purge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magiclen","download_url":"https://codeload.github.com/magiclen/nginx-cache-purge/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fnginx-cache-purge/sbom","scorecard":{"id":611783,"data":{"date":"2025-08-11","repo":{"name":"github.com/magiclen/nginx-cache-purge","commit":"02b02177a92566a601f392bad7d031f9e09773d1"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.9,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/28 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci-version.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/magiclen/nginx-cache-purge/ci-version.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci-version.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/magiclen/nginx-cache-purge/ci-version.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci-version.yml:55: update your workflow using https://app.stepsecurity.io/secureworkflow/magiclen/nginx-cache-purge/ci-version.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci-version.yml:56: update your workflow using https://app.stepsecurity.io/secureworkflow/magiclen/nginx-cache-purge/ci-version.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/magiclen/nginx-cache-purge/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/magiclen/nginx-cache-purge/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/magiclen/nginx-cache-purge/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/magiclen/nginx-cache-purge/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/magiclen/nginx-cache-purge/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/magiclen/nginx-cache-purge/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:47: update your workflow using https://app.stepsecurity.io/secureworkflow/magiclen/nginx-cache-purge/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:71: update your workflow using https://app.stepsecurity.io/secureworkflow/magiclen/nginx-cache-purge/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:72: update your workflow using https://app.stepsecurity.io/secureworkflow/magiclen/nginx-cache-purge/ci.yml/master?enable=pin","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   7 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci-version.yml:1","Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact v0.4.4 not signed: https://api.github.com/repos/magiclen/nginx-cache-purge/releases/131549561","Warn: release artifact v0.4.2 not signed: https://api.github.com/repos/magiclen/nginx-cache-purge/releases/129041080","Warn: release artifact v0.4.1 not signed: https://api.github.com/repos/magiclen/nginx-cache-purge/releases/129025563","Warn: release artifact v0.4.0 not signed: https://api.github.com/repos/magiclen/nginx-cache-purge/releases/129016394","Warn: release artifact v0.3.2 not signed: https://api.github.com/repos/magiclen/nginx-cache-purge/releases/129007551","Warn: release artifact v0.4.4 does not have provenance: https://api.github.com/repos/magiclen/nginx-cache-purge/releases/131549561","Warn: release artifact v0.4.2 does not have provenance: https://api.github.com/repos/magiclen/nginx-cache-purge/releases/129041080","Warn: release artifact v0.4.1 does not have provenance: https://api.github.com/repos/magiclen/nginx-cache-purge/releases/129025563","Warn: release artifact v0.4.0 does not have provenance: https://api.github.com/repos/magiclen/nginx-cache-purge/releases/129016394","Warn: release artifact v0.3.2 does not have provenance: https://api.github.com/repos/magiclen/nginx-cache-purge/releases/129007551"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T02:50:37.385Z","repository_id":57644923,"created_at":"2025-08-21T02:50:37.385Z","updated_at":"2025-08-21T02:50:37.385Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001268,"owners_count":26083040,"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-10-09T02:00:07.460Z","response_time":59,"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","cli","nginx","rust"],"created_at":"2024-11-24T15:12:29.780Z","updated_at":"2025-10-09T10:34:41.213Z","avatar_url":"https://github.com/magiclen.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Nginx Cache Purge\n====================\n\n[![CI](https://github.com/magiclen/nginx-cache-purge/actions/workflows/ci.yml/badge.svg)](https://github.com/magiclen/nginx-cache-purge/actions/workflows/ci.yml)\n\nAn alternative way to do `proxy_cache_purge` or `fastcgi_cache_purge` for Nginx.\n\n## Usage\n\n### Installation / Uninstallation\n\nFrom [crates.io](https://crates.io/crates/nginx-cache-purge),\n\n```bash\ncargo install nginx-cache-purge\n\n# cargo uninstall nginx-cache-purge\n```\n\nFrom GitHub (Linux x86_64),\n\n```bash\ncurl -fL \"$(curl -fsS https://api.github.com/repos/magiclen/nginx-cache-purge/releases/latest | sed -r -n 's/.*\"browser_download_url\": *\"(.*\\/nginx-cache-purge_'$(uname -m)')\".*/\\1/p')\" -O \u0026\u0026 sudo mv nginx-cache-purge_$(uname -m) /usr/local/bin/nginx-cache-purge \u0026\u0026 sudo chmod +x /usr/local/bin/nginx-cache-purge\n\n# sudo rm /usr/local/bin/nginx-cache-purge\n```\n\n### CLI Help\n\n```\nEXAMPLES:\nnginx-cache-purge p /path/to/cache 1:2 http/blog/             # Purge the cache with the key \"http/blog/\" in the \"cache zone\" whose \"path\" is /path/to/cache, \"levels\" is 1:2\nnginx-cache-purge p /path/to/cache 1:1:1 'http/blog*'         # Purge the caches with the key which has \"http/blog\" as its prefix in the \"cache zone\" whose \"path\" is /path/to/cache, \"levels\" is 1:1:1\nnginx-cache-purge p /path/to/cache 2:1 '*/help*'              # Purge the caches with the key which contains the substring \"/help\" in the \"cache zone\" whose \"path\" is /path/to/cache, \"levels\" is 2:1\nnginx-cache-purge p /path/to/cache 1 '*'                      # Purge all caches in the \"cache zone\" whose \"path\" is /path/to/cache, \"levels\" is 1\nnginx-cache-purge p /path/to/cache 2 '*' -e 'http/static/*'   # Purge all caches except for those whose key starts with \"http/static/\" in the \"cache zone\" whose \"path\" is /path/to/cache, \"levels\" is 2\nnginx-cache-purge s                                           # Start a server which listens on \"/tmp/nginx-cache-purge.sock\" to handle purge requests\nnginx-cache-purge s /run/nginx-cache-purge.sock               # Start a server which listens on \"/run/nginx-cache-purge.sock\" to handle purge requests\n\nUsage: nginx-cache-purge \u003cCOMMAND\u003e\n\nCommands:\n  purge  Purge the cache immediately [aliases: p]\n  start  Start a server to handle purge requests [aliases: s]\n  help   Print this message or the help of the given subcommand(s)\n\nOptions:\n  -h, --help     Print help\n  -V, --version  Print version\n```\n\nIf the `purge` command successfully removes any cache, it returns the exit status **0**. If no cache needs to be removed, it returns the exit status **44**.\n\n### Nginx + Nginx Cache Purge\n\n#### Start the Service of Nginx Cache Purge (systemd for example)\n\nAssume we have already put the executable file `nginx-cache-purge` in `/usr/local/bin/`.\n\n**/etc/systemd/system/nginx-cache-purge.service**\n\n```\n[Unit]\nDescription=Nginx Cache Purge\nAfter=network.target\n \n[Service]\n# same as the user/group of the nginx process\nUser=www-data\nGroup=www-data\n\nExecStart=/usr/local/bin/nginx-cache-purge start\nRestart=always\nRestartSec=3s\n \n[Install]\nWantedBy=multi-user.target\n```\n\nRun the following commands,\n\n```bash\nsudo systemctl daemon-reload\nsudo systemctl start nginx-cache-purge\nsudo systemctl status nginx-cache-purge\n\nsudo systemctl enable nginx-cache-purge\n```\n\n#### Edit Nginx' Configuration File\n\nAssume we want to put the cache in `/tmp/cache`.\n\n```nginx\nhttp {\n    ...\n\n    map $request_method $is_purge {                                                             \n        default   0;\n        PURGE     1;\n    }\n\n    proxy_cache_path /tmp/cache levels=1:2 keys_zone=my_cache:10m;\n    proxy_cache_key $scheme$request_uri;\n\n    server {\n        ...\n\n        location / {\n            if ($is_purge) {\n                set $my_cache_key $scheme$request_uri;\n            \n                proxy_pass http://unix:/tmp/nginx-cache-purge.sock;\n                \n                rewrite ^ /?cache_path=/tmp/cache\u0026levels=1:2\u0026key=$my_cache_key break;\n            }\n\n            proxy_cache my_cache;\n            proxy_pass upstream;\n            include proxy_params;\n        }\n    }\n}\n```\n\nRemember to add your access authentication mechanisms to prevent strangers from purging your cache. And note that the cache key should not contain `$proxy_host` because it will be empty when the request is in `proxy_pass http://unix:...`.\n\nAfter finishing the settings:\n\n* Request `PURGE /path/to/abc` to purge the cache from `GET /path/to/abc`.\n* Request `PURGE /path/to/*` to purge all caches from `GET /path/to/**/*`.\n* Request `PURGE /path/to/*/foo/*/bar` to purge caches from `GET /path/to/**/foo/**/bar`.\n\nIf the service successfully removes any cache, it will respond the HTTP status code **200**. If no cache needs to be removed, it will respond the HTTP status code **202**.\n\nOther fields that can be set to the query of the `/` endpoint URL:\n\n* `remove_first`: Allow the exclusion of the prefix from the request path of the `key`. The format should be like `?remove_first=/purge`.\n* `exclude_keys` (can be more than one): Exclude those keys from the purging process. It also supports the use of wildcards. The format should be like `?exclude_keys=http/static/*\u0026exclude_keys=http/1`. The `remove_first` field does not affect `exclude_keys` fields.\n\n### No Service\n\nIf we want to use `nginx-cache-purge` CLI with [lua-nginx-module](https://github.com/openresty/lua-nginx-module), instead of running the service in the background.\n\nWe can choose to disable the default features to obtain a much smaller executable binary.\n\n```bash\ncargo install nginx-cache-purge --no-default-features\n```\n\n## License\n\n[MIT](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclen%2Fnginx-cache-purge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagiclen%2Fnginx-cache-purge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclen%2Fnginx-cache-purge/lists"}