commit 88a0531d90b6b7c688b66c662d8a03f4d8e32b6a Author: Kevin Bataille Date: Sun Sep 13 09:20:32 2026 +0200 Add initial design document for WP Recache diff --git a/docs/plans/2026-09-13-wprecache-design.md b/docs/plans/2026-09-13-wprecache-design.md new file mode 100644 index 0000000..462550c --- /dev/null +++ b/docs/plans/2026-09-13-wprecache-design.md @@ -0,0 +1,226 @@ +# WP Recache — Open Source Performance Plugin + +## Overview + +Create a commercial-grade WordPress performance plugin with feature parity to WP Rocket, implemented via clean-room methodology. The plugin will be open source (GPL-2.0+) and provide page caching, file optimization, and image optimization. + +## Clean-Room Methodology + +### Rules + +1. **No code reuse.** Never copy, paste, or adapt any PHP/JS/CSS from WP Rocket. +2. **Feature specs only.** Document what WP Rocket does from a *user perspective* (UI behavior, options, output), not how it's implemented. +3. **Independent implementation.** All code written from scratch using WordPress APIs and standard libraries. +4. **Documentation trail.** Keep records of the specification process to prove independent development. + +### What We Study (User Perspective) + +- WP Rocket admin UI: what settings exist, what they control +- Frontend output: what HTML/JS/CSS changes appear after activation +- Behavior: when cache clears, what gets optimized, what's excluded by default +- Performance: what metrics improve + +### What We Ignore + +- PHP source code structure +- Internal class/function naming +- Specific implementation patterns +- Hook naming conventions + +## Feature Specifications + +### 1. Page Cache + +**User-facing behavior:** +- On first anonymous visit, generates static HTML file +- Subsequent anonymous visits serve the static file directly +- Cache auto-purges when content is published/updated +- Manual purge available from admin bar and settings page +- Excludes logged-in users, cart/checkout pages, specific URLs +- Separate cache for mobile devices (optional) +- Preload/crawl sitemap to warm cache + +**Technical approach (independent implementation):** +- Use WordPress `advanced-cache.php` drop-in +- Output buffering via `ob_start()` / `ob_get_contents()` / `ob_end_flush()` +- Cache files stored in `wp-content/cache/` +- Serve cached files via direct file read before WordPress loads +- Use WordPress rewrite rules for cache detection + +### 2. File Optimization — CSS + +**User-facing behavior:** +- Minify CSS files (remove whitespace, comments) +- Combine CSS files into fewer requests +- Defer non-critical CSS loading +- Remove unused CSS (RUCSS — Remove Unused CSS) +- Inline critical CSS for above-the-fold content +- Async CSS loading + +**Technical approach:** +- Use CSS minification library (e.g., `natanielrodman/css-minify` or similar) +- Parse CSS to identify critical path selectors +- Output buffering to detect and modify `` tags +- Generate critical CSS via headless browser or parser + +### 3. File Optimization — JavaScript + +**User-facing behavior:** +- Minify JavaScript files +- Combine JavaScript files +- Defer JavaScript loading (load after HTML parsed) +- Delay JavaScript execution (load on user interaction) +- Remove jQuery Migrate +- Delay inline scripts + +**Technical approach:** +- Use JavaScript minification (e.g., `tedivm/jshrink` or similar) +- Output buffering to modify `