https://github.com/levidurfee/nginx-cache-hit-parser
Parse nginx FastCGI cache hit log file
https://github.com/levidurfee/nginx-cache-hit-parser
Last synced: about 1 year ago
JSON representation
Parse nginx FastCGI cache hit log file
- Host: GitHub
- URL: https://github.com/levidurfee/nginx-cache-hit-parser
- Owner: levidurfee
- Created: 2015-12-27T21:25:30.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-12-27T22:00:44.000Z (over 10 years ago)
- Last Synced: 2025-02-27T00:50:18.614Z (over 1 year ago)
- Language: PHP
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nginx-cache-hit-parser
[](https://travis-ci.org/levidurfee/nginx-cache-hit-parser)
[]()
Parse a nginx FastCGI cache hit log file.
## nginx config
This isn't verbatim - i assume you know what you're doing.
```nginx
log_format cache '$request_method $uri $sent_http_x_cache $bytes_sent $request_time';
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_path /tmp/nginx levels=1:2 keys_zone=website:100m inactive=60m;
access_log /var/log/nginx/website.cache.txt cache buffer=128k;
add_header X-Cache $upstream_cache_status;
location ~ \.php$ {
fastcgi_cache website;
fastcgi_cache_valid 200 60m;
fastcgi_cache_methods GET HEAD; # Only GET and HEAD methods apply
#normal php stuff
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/website$fastcgi_script_name;
include fastcgi_params;
}
```
## PHP usage example
```php
analyze();
```
## sample output
```bash
Website
| Page | HITS | MISS | EXPIR | TIME | RATIO
| /index.php | 55 | 18 | 3 | 0.005 | 72.36
```