added maple performance caching plugin

This commit is contained in:
rodolfomartinez 2026-02-02 12:35:28 -05:00
parent c44c49a836
commit e468202f95
12 changed files with 4501 additions and 0 deletions

View file

@ -0,0 +1,228 @@
# Maple Performance WP 🍁
A lightweight, privacy-focused WordPress performance plugin. No external dependencies, no tracking, no upsells.
**Built by [Maple Open Tech](https://mapleopentech.ca) for Canadian businesses who care about data sovereignty.**
## Features
### Page Caching
- Static HTML file generation
- Gzip pre-compression
- Brotli pre-compression (if PHP extension installed)
- Smart cache invalidation on content updates
- Automatic exclusion for logged-in users
### Asset Optimization
- **HTML**: Minification, comment removal
- **CSS**: Minification, aggregation, optional async loading
- **JavaScript**: Minification, aggregation (disabled by default for safety)
- **Google Fonts**: Combine multiple requests, add display:swap, optional deferred loading
### Lazy Loading
- Native `loading="lazy"` for images
- Native `loading="lazy"` for iframes
- Exclude LCP/hero images from lazy loading
### Extra Optimizations
- Remove WordPress emoji scripts
- Remove query strings from static resources
- DNS prefetch hints
- Preconnect to third-party domains
### Smart Plugin Compatibility
Maple Performance automatically detects these plugins and applies safe exclusions:
| Plugin | Automatic Protections |
|--------|----------------------|
| **WooCommerce** | Cart/checkout/account pages excluded from cache, WooCommerce cookies bypass cache, cart fragments and checkout scripts protected |
| **LearnDash** | Lesson/topic/quiz pages excluded, progress tracking AJAX protected, quiz scripts excluded from aggregation |
| **WPForms** | Form validation scripts excluded, AJAX submissions protected |
| **Wordfence** | Security scripts excluded, login pages not cached, firewall bypass cookies respected |
| **Gravity Forms** | Form scripts excluded from aggregation |
| **Contact Form 7** | Form scripts excluded from aggregation |
| **Elementor** | Builder scripts excluded from aggregation |
## Site Modes
Select your site type and Maple Performance automatically applies safe defaults:
| Site Type | JS Aggregate | CSS Defer | Expected Score |
|-----------|--------------|-----------|----------------|
| Brochure/Blog | ✅ Available | ✅ Available | 80-95 |
| WooCommerce | ❌ Disabled | ❌ Disabled | 70-85 |
| LearnDash | ❌ Disabled | ❌ Disabled | 70-85 |
| WooCommerce + LearnDash | ❌ Disabled | ❌ Disabled | 65-80 |
## Installation
### From GitHub
1. Download or clone this repository
2. Upload the `maple-performance-wp` folder to `/wp-content/plugins/`
3. Activate through WordPress admin
4. Go to Settings > Maple Performance
5. Select your site type and configure
### From WordPress Admin
1. Go to Plugins > Add New
2. Upload the zip file
3. Activate and configure
## Configuration
### Brochure Sites (Maximum Performance)
```
Site Mode: Brochure
Cache: Enabled
HTML Minify: On
CSS Minify: On
CSS Aggregate: On
CSS Defer: On (optional)
JS Minify: On
JS Aggregate: On
Lazy Load: On
```
### WooCommerce Sites (Safe Defaults)
```
Site Mode: WooCommerce
Cache: Enabled (cart/checkout excluded)
HTML Minify: On
CSS Minify: On
CSS Aggregate: On
CSS Defer: Off
JS Minify: On
JS Aggregate: Off (protects checkout)
Lazy Load: On
```
### LearnDash Sites (Safe Defaults)
```
Site Mode: LearnDash
Cache: Enabled (lessons excluded for logged-in)
HTML Minify: On
CSS Minify: On
CSS Aggregate: On
CSS Defer: Off
JS Minify: On
JS Aggregate: Off (protects tracking)
Lazy Load: On
```
## Privacy
This plugin:
- ✅ Processes everything locally on your server
- ✅ Makes zero external API calls
- ✅ Sends no data to third parties
- ✅ Has no tracking or analytics
- ✅ Has no premium upsells or nags
- ✅ Is fully open source (GPL-2.0)
## Privacy & GDPR Compliance
Maple Performance WP is designed with privacy as a core principle:
| Aspect | Status |
|--------|--------|
| Personal data collection | ❌ None |
| Cookies set by plugin | ❌ None |
| External connections | ❌ None |
| Tracking/analytics | ❌ None |
| Third-party services | ❌ None |
### What the plugin stores
- **Page cache**: Static HTML copies of publicly-visible pages (same content any visitor sees)
- **Asset cache**: Aggregated/minified CSS and JS files
- **Settings**: Your plugin configuration (no personal data)
### Cookie behavior
The plugin **reads** existing cookies (WordPress login, WooCommerce cart) only to determine whether to serve cached content. It never sets, modifies, or transmits cookie data.
### Privacy Policy
The plugin automatically registers suggested privacy policy text with WordPress (Settings → Privacy) that you can include in your site's privacy policy.
## Requirements
- WordPress 5.9+
- PHP 7.4+
- Write access to `wp-content/cache/`
## Cache Location
Cached files are stored in:
```
wp-content/cache/maple-performance/
├── assets/ # Aggregated CSS/JS files
├── {domain}/ # Page cache by domain
│ └── {path}/ # Page cache by URL path
│ ├── https-index.html
│ ├── https-index.html.gz
│ └── https-index.html.br
```
## Hooks & Filters
### Actions
```php
// Clear all cache
do_action( 'maple_performance_clear_cache' );
// After cache is cleared
do_action( 'maple_performance_cache_cleared' );
```
### Filters
```php
// Modify settings programmatically
add_filter( 'maple_performance_settings', function( $settings ) {
$settings['cache_enabled'] = false;
return $settings;
});
// Exclude specific URLs from caching
add_filter( 'maple_performance_exclude_url', function( $exclude, $url ) {
if ( strpos( $url, '/members/' ) !== false ) {
return true;
}
return $exclude;
}, 10, 2 );
```
## Comparison
| Feature | Maple Performance | Autoptimize | Cache Enabler | WP Rocket |
|---------|------------------|-------------|---------------|-----------|
| Page Cache | ✅ | ❌ | ✅ | ✅ |
| CSS/JS Minify | ✅ | ✅ | ❌ | ✅ |
| CSS/JS Aggregate | ✅ | ✅ | ❌ | ✅ |
| Google Fonts Optimization | ✅ | ✅ | ❌ | ✅ |
| External Dependencies | ❌ None | ⚠️ Optional | ⚠️ CDN promo | ✅ Required |
| Tracking | ❌ None | ⚠️ News feed | ❌ None | ✅ License |
| Upsells | ❌ None | ✅ Yes | ✅ Yes | N/A (paid) |
| WooCommerce Safe Mode | ✅ | ❌ | ❌ | ✅ |
| LearnDash Safe Mode | ✅ | ❌ | ❌ | ❌ |
| Price | Free | Free | Free | $59/year |
## Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
## License
GPL-2.0-or-later - see [LICENSE](LICENSE) for details.
## Credits
Built by [Maple Open Tech](https://mapleopentech.ca) 🍁
Inspired by the core concepts from Autoptimize and Cache Enabler, rebuilt from scratch with privacy and safety in mind.