=== VaryCache === Contributors: gkap186, kap186 Tags: cache, a/b testing, geo targeting, personalization, performance Requires at least: 5.0 Tested up to: 6.9 Stable tag: 1.2.0 Requires PHP: 7.4 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html Advanced variant-based caching system for A/B testing, geo-targeting, and query parameter variations. Serve different cached versions of pages. == Description == VaryCache is a powerful caching plugin that allows you to serve different versions of cached pages based on various conditions: = Key Features = * **A/B Testing** - Create multiple A/B tests with weighted variants * **Geo Targeting** - Serve different content based on visitor's country * **Query Parameters** - Cache variations based on URL parameters (UTM, etc.) * **REST API Caching** - Cache REST API responses for improved performance * **Cache Preload** - Automatic and manual cache warming from sitemap * **Browser Cache Headers** - Cache-Control, Expires, Last-Modified headers * **Link Prefetch/Prerender** - Instant page navigation on hover (Speculation Rules API) * **Speed Optimizations** - HTML minification, DNS prefetch, preload hints * **Disable Emoji** - Remove WordPress emoji scripts to save bandwidth * **Remove Query Strings** - Remove ?ver= from static resources * **Image Dimensions** - Auto-add missing width/height to prevent CLS * **File-based Caching** - Fast, lightweight caching without database overhead * **CDN Compatible** - Works with CloudFront, Cloudflare, and other CDNs * **WP Rocket Integration** - Seamlessly integrates with WP Rocket caching * **Debug Panel** - Visual debugging panel for testing * **Shortcodes** - Easy content switching with shortcodes * **PHP Functions** - Helper functions for theme developers * **Multisite Support** - Full multisite compatibility = Use Cases = * Run A/B tests on landing pages * Show different pricing based on user's country * Personalize content for different traffic sources (UTM parameters) * Test different headlines, CTAs, or layouts * Serve localized content based on geo location = How It Works = 1. Configure your tests, geo rules, or query parameters in the admin panel 2. Add shortcodes to your pages or use PHP functions in your theme 3. The plugin creates separate cached versions for each variant 4. Visitors are automatically assigned variants based on your rules = Shortcodes = `[varycache_ab v="A"]Content for variant A[/varycache_ab]` `[varycache_ab v="B"]Content for variant B[/varycache_ab]` `[varycache_ab test="pricing" v="X"]Content for specific test[/varycache_ab]` `[varycache_geo country="US"]Content for US visitors[/varycache_geo]` = PHP Functions = `if ( varycache_is_variant( 'A' ) ) { // Show variant A content }` `if ( varycache_is_geo( 'US' ) ) { // Show US-specific content }` = Page Patterns = Flexible page matching with wildcards and regex: * `/` - Homepage only * `/blog/*` - Single segment wildcard * `/blog/**` - Any depth wildcard * `~^/post/\d+$` - Regular expression = Requirements = * WordPress 5.0 or higher * PHP 7.4 or higher * Write access to wp-content directory == Installation == 1. Upload the `varycache` folder to the `/wp-content/plugins/` directory 2. Activate the plugin through the 'Plugins' menu in WordPress 3. Go to Settings > VaryCache to configure = Basic Setup = 1. Enable caching in the settings 2. Create an A/B test or enable geo targeting 3. Add pages where you want variant caching 4. Use shortcodes in your content to show different versions = WP Rocket Integration = If using WP Rocket, exclude pages with variant caching from WP Rocket's cache: 1. Go to WP Rocket > Advanced Rules 2. Add your test pages to "Never Cache URLs" == Frequently Asked Questions == = Does this work with page builders? = Yes! The shortcodes work with any page builder including Elementor, Gutenberg, Divi, and others. = How are visitors assigned to variants? = For A/B tests, visitors are randomly assigned based on configured weights and stored in a cookie. For geo targeting, the country is detected from HTTP headers (CloudFront-Viewer-Country, CF-IPCountry). = Does this affect SEO? = No. Search engines see the default variant and the canonical URL remains the same. = Can I run multiple A/B tests? = Yes! You can create multiple independent A/B tests with different pages and variants. = How long are variants cached? = You can configure the cache TTL (time to live) in settings. Default is 1 hour. = Does this work with CDNs? = Yes, but you need to configure your CDN to pass through cookies and country headers. == Screenshots == 1. A/B Tests configuration 2. Geo targeting settings 3. Query parameters configuration 4. Cache report 5. Debug panel on frontend == Changelog == = 1.2.0 = * NEW: Speed optimization tab with performance features * NEW: HTML Minification - reduce page size by removing whitespace * NEW: DNS Prefetch - pre-resolve external domains for faster loading * NEW: Preload critical resources (fonts, CSS, images) for better LCP * NEW: Remove query strings from static resources for better CDN caching * NEW: Disable WordPress emoji scripts to save ~15KB * NEW: Auto-add missing image dimensions to prevent CLS * IMPROVED: Reorganized admin UI with logical grouping * IMPROVED: Moved Link Prefetch and Browser Cache to Speed tab * IMPROVED: Better separation of concerns in code * Core Web Vitals optimizations: LCP, CLS improvements = 1.1.0 = * NEW: REST API caching - cache REST endpoints to reduce server load * NEW: Cache Preload - automatic and manual cache warming from sitemap * NEW: Browser Cache Headers - Cache-Control, Expires, Last-Modified, Vary * NEW: Page Cache admin tab with all caching settings * NEW: Test REST endpoints for debugging (/varycache/v1/test) * IMPROVED: Admin interface with better organization * IMPROVED: WordPress.org compliance updates * IMPROVED: Changed prefix from 'vc' to 'varycache' per WordPress.org guidelines * IMPROVED: Moved settings file to uploads directory per WordPress.org guidelines * IMPROVED: Scripts now properly enqueued using wp_enqueue_script * FIX: Various security improvements and code cleanup = 1.0.0 = * Initial release * A/B testing with weighted variants * Geo targeting via CloudFront/Cloudflare headers * Query parameter caching * Page pattern matching (wildcards, regex) * Admin settings panel with tabs * Cache management and reporting * Debug panel * Shortcodes and PHP helper functions * WP Rocket integration == Upgrade Notice == = 1.2.0 = New Speed tab with Core Web Vitals optimizations: HTML minification, DNS prefetch, preload hints, disable emoji, image dimensions. Highly recommended. = 1.1.0 = New features: REST API caching, Cache Preload, Browser Cache Headers. Recommended update. = 1.0.0 = Initial release.