serkanalgur/nginx-opcache-manager
Composer 安装命令:
composer require serkanalgur/nginx-opcache-manager
包简介
WordPress plugin to manage and monitor Nginx cache and PHP Opcache with analytics
README 文档
README
A powerful WordPress plugin to monitor and manage Nginx cache and PHP Opcache directly from the WordPress Dashboard.
Features
- Real-time Monitoring: Display live statistics for both Nginx cache and PHP Opcache
- Nginx Cache Management:
- View cache size and number of cached files
- Clear cache with one click
- Configure cache path
- PHP Opcache Management:
- Monitor hit rate, memory usage, and cached scripts
- Reset opcache with one click
- Track miss rate and performance metrics
- Analytics Dashboard:
- Beautiful charts showing cache performance over time
- Historical data logging
- Memory usage trends
- Hit/Miss ratio visualization
- WordPress Dashboard Widget: Quick cache status overview on WordPress dashboard
- Settings Page: Easy configuration of plugin options
- Performance Metrics: Get insights into cache effectiveness
Requirements
- WordPress 4.7 or higher
- PHP 7.2 or higher
- Nginx web server (for cache management features)
- PHP Opcache extension (for opcache features)
Installation
- Upload the
nginx-opcache-managerfolder to the/wp-content/plugins/directory - Activate the plugin through the 'Plugins' menu in WordPress
- Navigate to 'Cache Manager' in the admin menu
- Configure the plugin settings if needed
Usage
Dashboard
The main dashboard shows:
- Nginx Cache Card: Current cache size, number of cached files, and cache path
- PHP Opcache Card: Hit rate, memory usage, and number of cached scripts
- Quick Actions: Clear cache and reset opcache buttons
Analytics Page
View detailed performance analytics:
- Cache size trends over time
- Opcache hit/miss ratio
- Memory usage visualization
- Historical data table with hourly records
Settings Page
Configure:
- Enable/disable Nginx cache monitoring
- Set Nginx cache path
- Enable/disable admin notifications
- View server information
AJAX Actions
The plugin provides several AJAX endpoints:
nom_get_stats
Get current cache statistics.
Request:
POST /wp-admin/admin-ajax.php
action: nom_get_stats
nonce: {nom_nonce}
Response:
{
"success": true,
"data": {
"nginx": {
"enabled": true,
"cache_size": 1048576,
"cached_files": 42,
"cache_path": "/var/run/nginx-cache"
},
"opcache": {
"enabled": true,
"hit_rate": 98.5,
"used_memory": 67108864,
"cached_scripts": 120
}
}
}
nom_clear_cache
Clear Nginx cache.
Request:
POST /wp-admin/admin-ajax.php
action: nom_clear_cache
nonce: {nom_nonce}
nom_reset_opcache
Reset PHP Opcache.
Request:
POST /wp-admin/admin-ajax.php
action: nom_reset_opcache
nonce: {nom_nonce}
Directory Structure
nginx-opcache-manager/
├── nginx-opcache-manager.php # Main plugin file
├── admin/
│ ├── class-admin.php # Admin menu and settings
│ ├── class-analytics.php # Analytics functionality
│ └── views/
│ ├── dashboard.php # Dashboard page template
│ ├── analytics.php # Analytics page template
│ ├── settings.php # Settings page template
│ └── dashboard-widget.php # Dashboard widget template
├── includes/
│ ├── class-nginx-cache-manager.php # Nginx cache management
│ ├── class-opcache-manager.php # PHP Opcache management
│ └── class-cache-stats.php # Statistics tracking
├── assets/
│ ├── css/
│ │ └── admin.css # Admin styles
│ └── js/
│ └── admin.js # Admin JavaScript
└── README.md
Classes Reference
Nginx_Opcache_Manager_Cache
Manages Nginx cache operations.
Methods:
is_enabled(): Check if nginx cache is enabledget_cache_size(): Get total cache size in bytesget_cached_files_count(): Get number of cached filesclear_cache(): Clear all nginx cacheclear_url_cache($url): Clear cache for specific URLget_cache_stats(): Get cache statisticsformat_bytes($bytes): Format bytes to human readable string
Nginx_Opcache_Manager_Opcache
Manages PHP Opcache operations.
Methods:
is_enabled(): Check if opcache is enabledget_status(): Get opcache statusget_config(): Get opcache configurationget_opcache_stats(): Get comprehensive opcache statisticsreset_opcache(): Reset opcacheinvalidate_file($file): Invalidate specific file cacheget_cached_files(): Get list of cached filesget_memory_percentage(): Get memory usage percentageformat_bytes($bytes): Format bytes to human readable string
Nginx_Opcache_Manager_Stats
Tracks and manages cache statistics.
Methods:
initialize(): Initialize statistics storageget_nginx_stats(): Get current nginx statisticsget_opcache_stats(): Get current opcache statisticsrecord_stats(): Record statistics to historyget_history($limit): Get statistics historyget_current_stats(): Get current statisticsget_dashboard_data(): Get data formatted for dashboardclear_history(): Clear all statistics history
Filter Hooks
None currently, but can be extended.
Action Hooks
nom_record_stats: Scheduled action to record statistics hourlywp_dashboard_setup: Used to register dashboard widget
Nginx Configuration
To ensure proper cache statistics collection, configure your Nginx server with a cache zone:
# Cache zone definition proxy_cache_path /var/run/nginx-cache levels=1:2 keys_zone=my_cache:10m max_size=1g inactive=60m; # Use in server block server { listen 80; server_name example.com; location ~ \.php$ { # PHP configuration proxy_cache my_cache; proxy_cache_valid 200 60m; } }
Update the "Nginx Cache Path" setting in the plugin to match your configuration.
Performance Considerations
- Statistics are recorded hourly to avoid excessive database usage
- Only the last 100 records are retained (approximately 24+ hours of data)
- Use read-only operations when monitoring to minimize server load
Troubleshooting
Nginx Cache Not Showing
- Verify the nginx cache path is correct in settings
- Check file permissions on the cache directory
- Ensure the PHP user has read access to the cache directory
Opcache Not Detected
- Verify opcache is installed:
php -m | grep opcache - Check opcache is enabled in php.ini:
opcache.enable = 1 - Verify opcache.enable_cli is not disabling it
No Statistics Data
- Clear the WordPress cache
- Wait for the hourly cron job to run
- Check WordPress error log for issues
Security
The plugin includes security measures:
- Nonce verification on all AJAX requests
- Capability checking (manage_options required)
- Sanitized and escaped output
- No privilege escalation
License
GPL v2 or later
Support
For issues and feature requests, please visit the plugin's support page.
Changelog
Version 1.1.0
- Added Cache Flush Activity Logging with persistent database storage
- Track all cache deletion operations with success/failure status
- Add post publication and modification tracking
- Display file paths for debugging and audit trails
- Added Customizable fastcgi_cache_key_schema setting
- Support for custom cache key formats
- Tag-based template system: $scheme, $request_method, $host, $request_uri, $query_string
- Added Clear Activity Logs button to manage database storage
- Fixed Fastcgi cache path calculation
- Corrected directory structure to use last 2 digits before final character
- Example:
/5/9f/beda56a8736ae8bc335cdd74983649f5(was/ed/a5/...)
- Fixed JavaScript type safety issue in escapeHtml() function
- Improved Memory optimization by reducing refresh interval from 5s to 30s
- Improved Activity log display with color-coded status indicators
- Added Debug logging for troubleshooting cache operations
Version 1.0.1
- Fixed JavaScript localization error where nomLocalize object was undefined
- Fixed Gauge charts not displaying in Live Performance Metrics section
- Fixed Canvas element sizing for proper Chart.js doughnut chart rendering
- Fixed Chart initialization requiring history data when none exists
- Improved Dashboard initialization to show charts immediately on first load
- Enhanced Confirmation dialogs for cache clearing and opcache reset operations
Version 1.0.0
- Initial release
- Nginx cache management
- PHP Opcache monitoring
- Analytics dashboard
- Statistics tracking
serkanalgur/nginx-opcache-manager 适用场景与选型建议
serkanalgur/nginx-opcache-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 03 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「cache」 「plugin」 「wordpress」 「optimization」 「nginx」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 serkanalgur/nginx-opcache-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 serkanalgur/nginx-opcache-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 serkanalgur/nginx-opcache-manager 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
repository php library
Laravel 5 - Repositories to the database layer
Rinvex Repository is a simple, intuitive, and smart implementation of Active Repository with extremely flexible & granular caching system for Laravel, used to abstract the data layer, making applications more flexible to maintain.
Plugin for YOURLS. Default tools to use in some laemmi plugins
Laravel 5 - Repositories to the database layer
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 34
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2026-03-31