Files
wp-recache/TESTING.md
T
kevin.bataille d2be239c3f fix: address Phase 1 code review findings
- Serve cache via template_redirect so feeds/404/REST are excluded and
  query conditionals work
- Bypass cache on query strings; key files by md5(host+path) to avoid
  collisions and support multisite
- Write wp-content/wp-recache-cache.php drop-in server and set WP_CACHE
  in wp-config.php so advanced-cache.php actually runs
- Only remove advanced-cache.php on deactivation when it is ours
- Respect DONOTCACHEPAGE, non-200 responses; bots read but never warm
  cache
- Fix comment purge (comment_post_ID) and heartbeat purge ($data arg)
- Fix exclude URLs textarea parsing; purge all when exclusions change
- Enqueue admin purge script on every admin-bar page, not just settings
- Sync tests, add TESTING.md manual test guide
2026-09-13 13:44:30 +02:00

66 lines
3.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Testing WP Recache (manual)
Environment: Docker (`docker-compose up -d`), or any WP ≥ 5.8 + PHP ≥ 7.4 install with the plugin symlinked into `wp-content/plugins/`.
## Activation
1. Activate the plugin.
2. Check `wp-config.php` contains `define('WP_CACHE', true); // Added by WP Recache.`
3. Check these files exist:
- `wp-content/advanced-cache.php`
- `wp-content/wp-recache-cache.php`
- `wp-content/cache/wp-recache/.htaccess` + `index.php`
## Core cache (issue #1 stories 1, 11, 12)
4. Anonymous visit (incognito) to a page twice:
- 1st: response header `X-WP-Recache: MISS`, file `md5(host + path) . '.html'` appears in `wp-content/cache/wp-recache/`.
- 2nd: `X-WP-Recache: HIT` (via WP) or `X-WP-Recache-Dropin: 1` (served before WP loaded).
5. Same URL with `?utm_source=test`: always MISS, no new cache file (query strings bypass).
6. Define `DONOTCACHEPAGE` on a page (e.g. in a must-use plugin): page never cached.
7. Logged-in visit: no `X-WP-Recache` headers, nothing cached (logged-in cookie also bypasses the drop-in).
## Exclusions (stories 46)
8. Settings → Cache → Exclude URLs: add `/about`, save, visit `/about` twice → never cached.
9. Default exclusions: `/cart`, `/checkout`, `/my-account` never cached.
10. Feeds (`/feed/`) and 404 pages: no `X-WP-Recache` MISS header, no cache file.
## Purge (stories 2, 3)
11. Edit a published post → its cache file and the homepage file are deleted.
12. Add a comment to a post → that post's cache file is deleted (not the comment ID's).
13. Admin bar → WP Recache → Purge All Cache (works on every admin page AND on the front-end admin bar, not just the settings page) → cache dir emptied.
14. Settings → Advanced → Purge All Cache button → same result.
15. Heartbeat purge: `wp.heartbeat.send('wp_recache_purge', 1)` in browser console on an admin page → next heartbeat tick purges all (check response `wp_recache_purged`).
## Mobile (story 7)
16. Enable "Separate Mobile Cache", visit once with a mobile UA (`curl -A "iPhone"`), once desktop → two files: `*-mobile.html`, `*-desktop.html`.
17. With mobile cache ON, the drop-in does not serve (falls through to WP path) — expected.
## Stats (story 9)
18. Settings → Cache → Cache Statistics shows file count and size matching `wp-content/cache/wp-recache/`.
## Multisite (story 10)
19. On a network: same path on two sites produces two different files (host+path in key). Purge on one site must not touch the other.
## Deactivation / uninstall
20. Deactivate: `advanced-cache.php`, `wp-recache-cache.php` removed, `WP_CACHE` marker line removed from `wp-config.php`.
21. If another plugin's `advanced-cache.php` exists (no "WP Recache" marker), deactivation must NOT delete it.
22. Uninstall: options deleted, `wp-content/cache/wp-recache/` removed.
## Automated
- `composer test` (PHPUnit, needs WP test suite via docker-compose).
- `composer phpstan`, `composer lint`.
## Known ceilings
- Drop-in ignores `cache_duration` TTL (no WP available to read the option); freshness relies on purge-on-update. Files are never served stale for edited content, only for TTL-based expiry.
- Preload toggle (story 8) has no crawler implementation yet.
- Purge on publish clears only the post + homepage; archives/taxonomy pages expire via TTL.