{"id":50854393,"url":"https://github.com/serkanalgur/nginx-opcache-manager","last_synced_at":"2026-06-14T17:05:17.755Z","repository":{"id":348210156,"uuid":"1196949213","full_name":"serkanalgur/nginx-opcache-manager","owner":"serkanalgur","description":"WordPress plugin to manage and monitor Nginx cache and PHP Opcache with analytics","archived":false,"fork":false,"pushed_at":"2026-03-31T08:21:38.000Z","size":52,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-31T09:41:08.937Z","etag":null,"topics":["nginx","opcache","wordpress","wordpress-plugin"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/serkanalgur.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/funding.yml","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},"funding":{"github":"serkanalgur"}},"created_at":"2026-03-31T07:31:38.000Z","updated_at":"2026-03-31T08:21:42.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/serkanalgur/nginx-opcache-manager","commit_stats":null,"previous_names":["serkanalgur/nginx-opcache-manager"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/serkanalgur/nginx-opcache-manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serkanalgur%2Fnginx-opcache-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serkanalgur%2Fnginx-opcache-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serkanalgur%2Fnginx-opcache-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serkanalgur%2Fnginx-opcache-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serkanalgur","download_url":"https://codeload.github.com/serkanalgur/nginx-opcache-manager/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serkanalgur%2Fnginx-opcache-manager/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34329751,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-14T02:00:07.365Z","response_time":62,"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":["nginx","opcache","wordpress","wordpress-plugin"],"created_at":"2026-06-14T17:05:17.185Z","updated_at":"2026-06-14T17:05:17.750Z","avatar_url":"https://github.com/serkanalgur.png","language":"PHP","funding_links":["https://github.com/sponsors/serkanalgur"],"categories":[],"sub_categories":[],"readme":"# Nginx Opcache Manager\n\nA powerful WordPress plugin to monitor and manage Nginx cache and PHP Opcache directly from the WordPress Dashboard.\n\n## Features\n\n- **Real-time Monitoring**: Display live statistics for both Nginx cache and PHP Opcache\n- **Nginx Cache Management**: \n  - View cache size and number of cached files\n  - Clear cache with one click\n  - Configure cache path\n- **PHP Opcache Management**:\n  - Monitor hit rate, memory usage, and cached scripts\n  - Reset opcache with one click\n  - Track miss rate and performance metrics\n- **Analytics Dashboard**:\n  - Beautiful charts showing cache performance over time\n  - Historical data logging\n  - Memory usage trends\n  - Hit/Miss ratio visualization\n- **WordPress Dashboard Widget**: Quick cache status overview on WordPress dashboard\n- **Settings Page**: Easy configuration of plugin options\n- **Performance Metrics**: Get insights into cache effectiveness\n\n## Requirements\n\n- WordPress 4.7 or higher\n- PHP 7.2 or higher\n- Nginx web server (for cache management features)\n- PHP Opcache extension (for opcache features)\n\n## Installation\n\n1. Upload the `nginx-opcache-manager` folder to the `/wp-content/plugins/` directory\n2. Activate the plugin through the 'Plugins' menu in WordPress\n3. Navigate to 'Cache Manager' in the admin menu\n4. Configure the plugin settings if needed\n\n## Usage\n\n### Dashboard\n\nThe main dashboard shows:\n- **Nginx Cache Card**: Current cache size, number of cached files, and cache path\n- **PHP Opcache Card**: Hit rate, memory usage, and number of cached scripts\n- **Quick Actions**: Clear cache and reset opcache buttons\n\n### Analytics Page\n\nView detailed performance analytics:\n- Cache size trends over time\n- Opcache hit/miss ratio\n- Memory usage visualization\n- Historical data table with hourly records\n\n### Settings Page\n\nConfigure:\n- Enable/disable Nginx cache monitoring\n- Set Nginx cache path\n- Enable/disable admin notifications\n- View server information\n\n## AJAX Actions\n\nThe plugin provides several AJAX endpoints:\n\n### `nom_get_stats`\nGet current cache statistics.\n\n**Request:**\n```\nPOST /wp-admin/admin-ajax.php\naction: nom_get_stats\nnonce: {nom_nonce}\n```\n\n**Response:**\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"nginx\": {\n      \"enabled\": true,\n      \"cache_size\": 1048576,\n      \"cached_files\": 42,\n      \"cache_path\": \"/var/run/nginx-cache\"\n    },\n    \"opcache\": {\n      \"enabled\": true,\n      \"hit_rate\": 98.5,\n      \"used_memory\": 67108864,\n      \"cached_scripts\": 120\n    }\n  }\n}\n```\n\n### `nom_clear_cache`\nClear Nginx cache.\n\n**Request:**\n```\nPOST /wp-admin/admin-ajax.php\naction: nom_clear_cache\nnonce: {nom_nonce}\n```\n\n### `nom_reset_opcache`\nReset PHP Opcache.\n\n**Request:**\n```\nPOST /wp-admin/admin-ajax.php\naction: nom_reset_opcache\nnonce: {nom_nonce}\n```\n\n## Directory Structure\n\n```\nnginx-opcache-manager/\n├── nginx-opcache-manager.php          # Main plugin file\n├── admin/\n│   ├── class-admin.php                # Admin menu and settings\n│   ├── class-analytics.php            # Analytics functionality\n│   └── views/\n│       ├── dashboard.php              # Dashboard page template\n│       ├── analytics.php              # Analytics page template\n│       ├── settings.php               # Settings page template\n│       └── dashboard-widget.php       # Dashboard widget template\n├── includes/\n│   ├── class-nginx-cache-manager.php # Nginx cache management\n│   ├── class-opcache-manager.php     # PHP Opcache management\n│   └── class-cache-stats.php         # Statistics tracking\n├── assets/\n│   ├── css/\n│   │   └── admin.css                 # Admin styles\n│   └── js/\n│       └── admin.js                  # Admin JavaScript\n└── README.md\n\n```\n\n## Classes Reference\n\n### `Nginx_Opcache_Manager_Cache`\n\nManages Nginx cache operations.\n\n**Methods:**\n- `is_enabled()`: Check if nginx cache is enabled\n- `get_cache_size()`: Get total cache size in bytes\n- `get_cached_files_count()`: Get number of cached files\n- `clear_cache()`: Clear all nginx cache\n- `clear_url_cache($url)`: Clear cache for specific URL\n- `get_cache_stats()`: Get cache statistics\n- `format_bytes($bytes)`: Format bytes to human readable string\n\n### `Nginx_Opcache_Manager_Opcache`\n\nManages PHP Opcache operations.\n\n**Methods:**\n- `is_enabled()`: Check if opcache is enabled\n- `get_status()`: Get opcache status\n- `get_config()`: Get opcache configuration\n- `get_opcache_stats()`: Get comprehensive opcache statistics\n- `reset_opcache()`: Reset opcache\n- `invalidate_file($file)`: Invalidate specific file cache\n- `get_cached_files()`: Get list of cached files\n- `get_memory_percentage()`: Get memory usage percentage\n- `format_bytes($bytes)`: Format bytes to human readable string\n\n### `Nginx_Opcache_Manager_Stats`\n\nTracks and manages cache statistics.\n\n**Methods:**\n- `initialize()`: Initialize statistics storage\n- `get_nginx_stats()`: Get current nginx statistics\n- `get_opcache_stats()`: Get current opcache statistics\n- `record_stats()`: Record statistics to history\n- `get_history($limit)`: Get statistics history\n- `get_current_stats()`: Get current statistics\n- `get_dashboard_data()`: Get data formatted for dashboard\n- `clear_history()`: Clear all statistics history\n\n## Filter Hooks\n\nNone currently, but can be extended.\n\n## Action Hooks\n\n- `nom_record_stats`: Scheduled action to record statistics hourly\n- `wp_dashboard_setup`: Used to register dashboard widget\n\n## Nginx Configuration\n\nTo ensure proper cache statistics collection, configure your Nginx server with a cache zone:\n\n```nginx\n# Cache zone definition\nproxy_cache_path /var/run/nginx-cache levels=1:2 keys_zone=my_cache:10m max_size=1g inactive=60m;\n\n# Use in server block\nserver {\n    listen 80;\n    server_name example.com;\n\n    location ~ \\.php$ {\n        # PHP configuration\n        proxy_cache my_cache;\n        proxy_cache_valid 200 60m;\n    }\n}\n```\n\nUpdate the \"Nginx Cache Path\" setting in the plugin to match your configuration.\n\n## Performance Considerations\n\n- Statistics are recorded hourly to avoid excessive database usage\n- Only the last 100 records are retained (approximately 24+ hours of data)\n- Use read-only operations when monitoring to minimize server load\n\n## Troubleshooting\n\n### Nginx Cache Not Showing\n1. Verify the nginx cache path is correct in settings\n2. Check file permissions on the cache directory\n3. Ensure the PHP user has read access to the cache directory\n\n### Opcache Not Detected\n1. Verify opcache is installed: `php -m | grep opcache`\n2. Check opcache is enabled in php.ini: `opcache.enable = 1`\n3. Verify opcache.enable_cli is not disabling it\n\n### No Statistics Data\n1. Clear the WordPress cache\n2. Wait for the hourly cron job to run\n3. Check WordPress error log for issues\n\n## Security\n\nThe plugin includes security measures:\n- Nonce verification on all AJAX requests\n- Capability checking (manage_options required)\n- Sanitized and escaped output\n- No privilege escalation\n\n## License\n\nGPL v2 or later\n\n## Support\n\nFor issues and feature requests, please visit the plugin's support page.\n\n## Changelog\n\n### Version 1.1.0\n- **Added** Cache Flush Activity Logging with persistent database storage\n  - Track all cache deletion operations with success/failure status\n  - Add post publication and modification tracking\n  - Display file paths for debugging and audit trails\n- **Added** Customizable fastcgi_cache_key_schema setting\n  - Support for custom cache key formats\n  - Tag-based template system: $scheme, $request_method, $host, $request_uri, $query_string\n- **Added** Clear Activity Logs button to manage database storage\n- **Fixed** Fastcgi cache path calculation\n  - Corrected directory structure to use last 2 digits before final character\n  - Example: `/5/9f/beda56a8736ae8bc335cdd74983649f5` (was `/ed/a5/...`)\n- **Fixed** JavaScript type safety issue in escapeHtml() function\n- **Improved** Memory optimization by reducing refresh interval from 5s to 30s\n- **Improved** Activity log display with color-coded status indicators\n- **Added** Debug logging for troubleshooting cache operations\n\n### Version 1.0.1\n- **Fixed** JavaScript localization error where nomLocalize object was undefined\n- **Fixed** Gauge charts not displaying in Live Performance Metrics section\n- **Fixed** Canvas element sizing for proper Chart.js doughnut chart rendering\n- **Fixed** Chart initialization requiring history data when none exists\n- **Improved** Dashboard initialization to show charts immediately on first load\n- **Enhanced** Confirmation dialogs for cache clearing and opcache reset operations\n\n### Version 1.0.0\n- Initial release\n- Nginx cache management\n- PHP Opcache monitoring\n- Analytics dashboard\n- Statistics tracking\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserkanalgur%2Fnginx-opcache-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserkanalgur%2Fnginx-opcache-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserkanalgur%2Fnginx-opcache-manager/lists"}