PHPackages                             serkanalgur/nginx-opcache-manager - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. serkanalgur/nginx-opcache-manager

ActiveWordpress-plugin[Caching](/categories/caching)

serkanalgur/nginx-opcache-manager
=================================

WordPress plugin to manage and monitor Nginx cache and PHP Opcache with analytics

v1.1.0(3mo ago)20GPL-2.0-or-laterPHPPHP &gt;=7.2CI passing

Since Mar 31Pushed 3mo agoCompare

[ Source](https://github.com/serkanalgur/nginx-opcache-manager)[ Packagist](https://packagist.org/packages/serkanalgur/nginx-opcache-manager)[ Docs](https://github.com/serkanalgur/nginx-opcache-manager)[ RSS](/packages/serkanalgur-nginx-opcache-manager/feed)WikiDiscussions main Synced 4w ago

READMEChangelog (3)Dependencies (5)Versions (4)Used By (0)

Nginx Opcache Manager
=====================

[](#nginx-opcache-manager)

A powerful WordPress plugin to monitor and manage Nginx cache and PHP Opcache directly from the WordPress Dashboard.

Features
--------

[](#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
------------

[](#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
------------

[](#installation)

1. Upload the `nginx-opcache-manager` folder to the `/wp-content/plugins/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Navigate to 'Cache Manager' in the admin menu
4. Configure the plugin settings if needed

Usage
-----

[](#usage)

### Dashboard

[](#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

[](#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

[](#settings-page)

Configure:

- Enable/disable Nginx cache monitoring
- Set Nginx cache path
- Enable/disable admin notifications
- View server information

AJAX Actions
------------

[](#ajax-actions)

The plugin provides several AJAX endpoints:

### `nom_get_stats`

[](#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`

[](#nom_clear_cache)

Clear Nginx cache.

**Request:**

```
POST /wp-admin/admin-ajax.php
action: nom_clear_cache
nonce: {nom_nonce}

```

### `nom_reset_opcache`

[](#nom_reset_opcache)

Reset PHP Opcache.

**Request:**

```
POST /wp-admin/admin-ajax.php
action: nom_reset_opcache
nonce: {nom_nonce}

```

Directory Structure
-------------------

[](#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
-----------------

[](#classes-reference)

### `Nginx_Opcache_Manager_Cache`

[](#nginx_opcache_manager_cache)

Manages Nginx cache operations.

**Methods:**

- `is_enabled()`: Check if nginx cache is enabled
- `get_cache_size()`: Get total cache size in bytes
- `get_cached_files_count()`: Get number of cached files
- `clear_cache()`: Clear all nginx cache
- `clear_url_cache($url)`: Clear cache for specific URL
- `get_cache_stats()`: Get cache statistics
- `format_bytes($bytes)`: Format bytes to human readable string

### `Nginx_Opcache_Manager_Opcache`

[](#nginx_opcache_manager_opcache)

Manages PHP Opcache operations.

**Methods:**

- `is_enabled()`: Check if opcache is enabled
- `get_status()`: Get opcache status
- `get_config()`: Get opcache configuration
- `get_opcache_stats()`: Get comprehensive opcache statistics
- `reset_opcache()`: Reset opcache
- `invalidate_file($file)`: Invalidate specific file cache
- `get_cached_files()`: Get list of cached files
- `get_memory_percentage()`: Get memory usage percentage
- `format_bytes($bytes)`: Format bytes to human readable string

### `Nginx_Opcache_Manager_Stats`

[](#nginx_opcache_manager_stats)

Tracks and manages cache statistics.

**Methods:**

- `initialize()`: Initialize statistics storage
- `get_nginx_stats()`: Get current nginx statistics
- `get_opcache_stats()`: Get current opcache statistics
- `record_stats()`: Record statistics to history
- `get_history($limit)`: Get statistics history
- `get_current_stats()`: Get current statistics
- `get_dashboard_data()`: Get data formatted for dashboard
- `clear_history()`: Clear all statistics history

Filter Hooks
------------

[](#filter-hooks)

None currently, but can be extended.

Action Hooks
------------

[](#action-hooks)

- `nom_record_stats`: Scheduled action to record statistics hourly
- `wp_dashboard_setup`: Used to register dashboard widget

Nginx Configuration
-------------------

[](#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
--------------------------

[](#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
---------------

[](#troubleshooting)

### Nginx Cache Not Showing

[](#nginx-cache-not-showing)

1. Verify the nginx cache path is correct in settings
2. Check file permissions on the cache directory
3. Ensure the PHP user has read access to the cache directory

### Opcache Not Detected

[](#opcache-not-detected)

1. Verify opcache is installed: `php -m | grep opcache`
2. Check opcache is enabled in php.ini: `opcache.enable = 1`
3. Verify opcache.enable\_cli is not disabling it

### No Statistics Data

[](#no-statistics-data)

1. Clear the WordPress cache
2. Wait for the hourly cron job to run
3. Check WordPress error log for issues

Security
--------

[](#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
-------

[](#license)

GPL v2 or later

Support
-------

[](#support)

For issues and feature requests, please visit the plugin's support page.

Changelog
---------

[](#changelog)

### Version 1.1.0

[](#version-110)

- **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

[](#version-101)

- **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

[](#version-100)

- Initial release
- Nginx cache management
- PHP Opcache monitoring
- Analytics dashboard
- Statistics tracking

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance82

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

91d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c0bdaace73a06876c30b91f86f99e206c4a8fe5bb7a1a1e91f159a5e2c98088?d=identicon)[serkanalgur](/maintainers/serkanalgur)

---

Top Contributors

[![serkanalgur](https://avatars.githubusercontent.com/u/353690?v=4)](https://github.com/serkanalgur "serkanalgur (10 commits)")

---

Tags

nginxopcachewordpresswordpress-pluginphppluginwordpresscacheoptimizationnginxOpcache

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/serkanalgur-nginx-opcache-manager/health.svg)

```
[![Health](https://phpackages.com/badges/serkanalgur-nginx-opcache-manager/health.svg)](https://phpackages.com/packages/serkanalgur-nginx-opcache-manager)
```

###  Alternatives

[wp-media/wp-rocket

Performance optimization plugin for WordPress

7491.3M3](/packages/wp-media-wp-rocket)[rtcamp/nginx-helper

Cleans nginx's fastcgi/proxy cache or redis-cache whenever a post is edited/published. Also provides cloudflare edge cache purging with Cache-Tags.

23617.0k1](/packages/rtcamp-nginx-helper)[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.3k10](/packages/helsingborg-stad-municipio)[alekseykorzun/memcached-wrapper-php

Optimized PHP 5 wrapper for Memcached extension that supports dog-piling, igbinary and local storage

2887.3k1](/packages/alekseykorzun-memcached-wrapper-php)[rarst/fragment-cache

WordPress plugin for partial and async caching of heavy front-end elements.

14015.3k2](/packages/rarst-fragment-cache)[bnomei/kirby3-php-cachedriver

PHP based Cache-Driver

112.7k](/packages/bnomei-kirby3-php-cachedriver)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
