{"id":32518332,"url":"https://github.com/curiouslearner/cache_sniper","last_synced_at":"2025-10-28T03:19:51.761Z","repository":{"id":319367315,"uuid":"947086802","full_name":"CuriousLearner/cache_sniper","owner":"CuriousLearner","description":"A small utility to detect page caching on CDNs","archived":false,"fork":false,"pushed_at":"2025-10-17T21:17:21.000Z","size":55,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-18T22:52:26.656Z","etag":null,"topics":["cache","cache-invalidation","devops-tools","rust","rust-lang","sre"],"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/CuriousLearner.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-12T06:09:26.000Z","updated_at":"2025-10-17T21:19:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"01bfe688-4ede-4f52-a905-5cbcc5da6d67","html_url":"https://github.com/CuriousLearner/cache_sniper","commit_stats":null,"previous_names":["curiouslearner/cache_sniper"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/CuriousLearner/cache_sniper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CuriousLearner%2Fcache_sniper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CuriousLearner%2Fcache_sniper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CuriousLearner%2Fcache_sniper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CuriousLearner%2Fcache_sniper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CuriousLearner","download_url":"https://codeload.github.com/CuriousLearner/cache_sniper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CuriousLearner%2Fcache_sniper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281378230,"owners_count":26490638,"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-28T02:00:06.022Z","response_time":60,"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","cache-invalidation","devops-tools","rust","rust-lang","sre"],"created_at":"2025-10-28T03:19:48.069Z","updated_at":"2025-10-28T03:19:51.752Z","avatar_url":"https://github.com/CuriousLearner.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀 CacheSniper - CDN \u0026 Cache Invalidation Tester 🛠️\n\nCacheSniper is a **Rust-based CLI tool** for testing **CDN caching behavior**.\nIt helps developers analyze **Cache-Control**, **ETag**, **Last-Modified**, and **Expires** headers\nto determine whether a webpage is being cached properly and how cache invalidation works.\n\n---\n\n## 📌 **Features**\n\n* **Parallel Scanning** - Analyze multiple URLs at the same time\n* **Cache Validation (`--validate`)** - Ensures cache consistency\n* **CDN-Specific Analysis** - Parse Cloudflare (CF-Cache-Status), Fastly (X-Cache), and generic CDN headers\n* **Smart Cache Verdicts** - Interprets cache status (HIT/MISS/DYNAMIC/BYPASS) with explanations\n* **CI/CD Integration** - `--exit-code` flag returns exit code 1 when caching fails (perfect for pipelines)\n* **JSON Output** - Export cache test results in JSON format with all CDN headers\n* **Save Results to File** - Use `--output` to store findings\n* **CDN Detection** - Automatically identifies 23+ CDN providers\n* **Prometheus Metrics** - Monitor CDN caching behavior over time (requires Redis)\n* **Comprehensive Tests** - 8+ unit tests covering CDN detection and cache validation\n* **Tabular \u0026 Colorized Output** - Easy-to-read terminal display\n\n---\n\n## 🔧 **Installation**\n\nEnsure you have **Rust installed**:\n\n```sh\ncurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\n```\n\nThen, clone and build:\n\n```bash\ngit clone https://github.com/CuriousLearner/cache_sniper.git\ncd cache_sniper\ncargo build --release\n```\n\nTo install globally:\n\n```bash\ncargo install --path .\n```\n\n**Optional:** Redis is only required if you want to use the `--metrics` flag for Prometheus monitoring. For basic cache checking, Redis is not needed.\n\n---\n\n## 🔥 **Usage**\n\n### **Basic Check**\n\nScan a single URL:\n\n```bash\ncache_sniper --url \"https://example.com\"\n```\n\n### **Scan Multiple URLs**\n\n```bash\ncache_sniper --urls \"https://example1.com\" \"https://example2.com\"\n```\n\n### **Enable JSON Output**\n\n```bash\ncache_sniper --url \"https://example.com\" --json\n```\n\n### **Save Results to a File**\n\n```bash\ncache_sniper --url \"https://example.com\" --json --output results.json\n```\n\n### **Start Prometheus Metrics Server**\n\nRun a metrics server at `http://localhost:9090/metrics`:\n\n```bash\ncache_sniper --metrics\n```\n\n**Note:** Metrics mode requires Redis to be running on `localhost:6379`. Install and start Redis:\n\n```bash\n# macOS\nbrew install redis\nbrew services start redis\n\n# Ubuntu/Debian\nsudo apt-get install redis-server\nsudo systemctl start redis\n\n# Other systems - see https://redis.io/download\n```\n\n### **Validate Cache Behavior (`--validate`)**\n\nCheck if caching is **working correctly** by sending a normal request and a `Cache-Control: no-cache` request, then comparing responses:\n\n```bash\ncache_sniper --url \"https://example.com\" --validate\n```\n\n**How it works:**\n\n- If `ETag`, `Last-Modified`, and response **do not change**, cache is working correctly. ✅\n- If **values change**, the cache **might not be working consistently**. ⚠️\n- If **no cache headers exist**, validation is skipped automatically. 🚨\n\n### **CI/CD Integration (`--exit-code`)**\n\nUse in CI pipelines to fail builds when caching is not properly configured:\n\n```bash\n# Fails with exit code 1 if caching is disabled or broken\ncache_sniper --url \"https://example.com\" --exit-code\n\n# Perfect for GitHub Actions, GitLab CI, CircleCI, etc.\ncache_sniper --url \"https://api.example.com\" --validate --exit-code --json\n```\n\n**Use cases:**\n- Verify CDN configuration after deployment\n- Ensure static assets are cacheable before merging PRs\n- Monitor cache behavior in staging environments\n\n---\n\n## 🔍 **CDN-Specific Features**\n\nCacheSniper understands CDN-specific headers and provides intelligent verdicts:\n\n### **Cloudflare**\n- **CF-Cache-Status**: HIT, MISS, EXPIRED, DYNAMIC, BYPASS, REVALIDATED\n- **CF-Ray**: Request ID for debugging\n- **Example verdict**: `\"HIT - Served from Cloudflare cache\"`\n\n### **Fastly / Akamai / Generic CDNs**\n- **X-Cache**: HIT, MISS\n- **X-Served-By**: Cache server identifier\n- **X-Cache-Hits**: Number of cache hits\n- **Age**: Cache age in seconds\n\n### **Example JSON Output**\n\n```json\n{\n  \"url\": \"https://www.rust-lang.org\",\n  \"is_cached\": true,\n  \"cache_verdict\": \"HIT - Served from github cache\",\n  \"cdn_provider\": \"github\",\n  \"x_cache\": \"HIT\",\n  \"x_cache_hits\": \"1\",\n  \"age\": \"16\",\n  \"cache_control\": \"max-age=600\",\n  \"etag\": \"\\\"68f16b7d-4899\\\"\"\n}\n```\n\n---\n\n## 📊 **Example Output**\n\n```bash\n🌍 Scanning: https://example.com\n🌐 CDN Provider: Cloudflare\n\n┌──────────────────┬───────────────────────────────┐\n│ 🔍 Header        ┆ 📜 Value                      │\n╞══════════════════╪═══════════════════════════════╡\n│ 🛠 Cache-Control  ┆ max-age=86400                 │\n├──────────────────┼───────────────────────────────┤\n│ 🔄 ETag          ┆ \"abc123\"                      │\n├──────────────────┼───────────────────────────────┤\n│ 📆 Last-Modified ┆ Tue, 11 Mar 2025 06:28:07 GMT │\n├──────────────────┼───────────────────────────────┤\n│ ⏳ Expires       ┆ None                          │\n└──────────────────┴───────────────────────────────┘\n\n✅ Success: This page is being cached!\n🔍 CF-Cache-Status: HIT\n⏱️  Age: 120 seconds\n\n📊 Verdict: HIT - Served from Cloudflare cache\n```\n\n### **Example Output for `--validate`**\n\n```bash\n🌍 Validating Cache for: https://example.com\n🔄 ETag Before: \"abc123\"\n🔄 ETag After : \"abc123\"\n📆 Last-Modified Before: Tue, 11 Mar 2025 06:28:07 GMT\n📆 Last-Modified After : Tue, 11 Mar 2025 06:28:07 GMT\n⏳ Age Header: 86400\n\n✅ Success: Cache is working correctly!\n```\n\nIf no cache headers are detected:\n\n```bash\n🚨 Warning: No caching detected on http://localhost:9001, skipping validation!\n```\n\n---\n\n## 🎯 **Why is this project helpful?**\n\n**CacheSniper** helps:\n\n- **DevOps engineers** debug caching behavior and identify stale content issues.\n- **SREs** ensure cache invalidation works in **CI/CD pipelines**.\n- **Security teams** detect **cache poisoning vulnerabilities**.\n- **Monitoring teams** track **real-time cache behavior** via Prometheus.\n\n---\n\n## 📜 **License**\n\nMIT License. Use freely and contribute!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuriouslearner%2Fcache_sniper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcuriouslearner%2Fcache_sniper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuriouslearner%2Fcache_sniper/lists"}