=== CacheLoop – Simple Page Cache & Speed Optimization ===
Contributors:      intouchdesigndev, ikaroweb
Tags:              cache, performance, speed, optimization, page cache
Requires at least: 6.2
Tested up to:      7.0
Requires PHP:      7.4
Stable tag:        1.0.18
License:           GPL-2.0-or-later
License URI:       https://www.gnu.org/licenses/gpl-2.0.html

Set-it-and-forget-it cache and speed optimization. Activate and go fast — no technical knowledge required.

== Description ==

**CacheLoop** is a WordPress performance plugin designed for everyone, not just developers.
Activate it and the most important speed optimizations are applied automatically.

= Free Features =

* **Page Cache** – Saves your pages as fast static HTML files so visitors get them instantly.
* **Browser Cache** – Tells browsers to remember static assets locally so repeat visits are blazing fast.
* **Gzip Compression** – Compresses pages before sending them to visitors, reducing data transfer.
* **Image Lazy Loading** – Loads images only when they scroll into view, speeding up initial page load.
* **Configurable Cache TTL** – Choose how long cached pages are served (1 hour to 7 days).
* **Device-Specific Cache** – Separate cache files for mobile and desktop visitors.
* **CDN Integration** – Rewrite asset URLs to serve them from your CDN (works with drop-in and PHP fallback).
* **Cache Whitelist / Blacklist** – Exclude or limit cached URLs with wildcard pattern support.
* **Cookie-Based Cache Bypass** – Skip cache when specific cookies are present.
* **Debug Log** – View cache hits, misses, and bypass reasons directly in admin.
* **Admin Toolbar Buttons** – "Clear All Cache" and "Purge This Page" from the WordPress admin bar.
* **HTTP/2 Server Push** – Preload critical CSS assets for faster rendering.
* **REST API Cache** – Cache common WordPress REST API endpoints (`/wp-json/wp/v2/*`).
* **WP-CLI Support** – Manage cache from the command line: `wp cacheloop clear`, `status`, `preload`, `log`.
* **Cache Metrics** – See file count, disk usage, and last purge time in the admin dashboard.

= CacheLoop Pro =

Unlock advanced optimizations:

* **CSS & JS Minification** – Removes unnecessary code from stylesheets and scripts and defers non-critical JS.
* **Database Optimization** – Weekly automatic cleanup of old drafts, revisions, and expired transients.
* **Cache Preloading** – Warms up the cache automatically by crawling your XML sitemap.
* **Server Resource Saver** – Limits WordPress background activity to reduce unnecessary server load.
* **Varnish Cache Purge** – Mirrors CacheLoop's own cache purges to an upstream Varnish server, keeping both layers in sync.
* **Cloudflare Cache Purge** – Mirrors CacheLoop's own cache purges to Cloudflare's edge via their API.
* **Unused CSS Removal** – Strips CSS rules unused on each page from the combined CSS output.

[Learn more about CacheLoop Pro](https://dev.intouchdesign.it/plugin/cacheloop/) →

== External services ==

This plugin provides a built-in speed testing tool to analyze your website's performance. When you click "Run PageSpeed" in the plugin settings, the plugin connects to the official Google PageSpeed Insights API to generate the performance report.

*   Service used: Google PageSpeed Insights API
*   Service URL: https://developers.google.com/speed/docs/insights/v5/about
*   Privacy Policy: https://policies.google.com/privacy
*   Terms of Service: https://policies.google.com/terms

== Installation ==

1. Upload the `cacheloop` folder to the `/wp-content/plugins/` directory.
2. Activate the plugin through the **Plugins** menu in WordPress.
3. That's it. CacheLoop applies optimal defaults immediately upon activation.
4. (Optional) Visit **CacheLoop** in your admin menu to review or adjust settings.

== Frequently Asked Questions ==

= Does CacheLoop work with WooCommerce? =

Yes. CacheLoop automatically skips caching for dynamic WooCommerce pages (cart, checkout, my-account) to ensure users always see accurate, up-to-date information.

= Does CacheLoop work with Nginx? =

The Browser Cache and Gzip features write to `.htaccess` and are Apache/LiteSpeed-only. The Page Cache and Lazy Load features work on all server types. Nginx users should configure browser caching at the server level.

= Will it conflict with my hosting provider's built-in caching? =

CacheLoop is designed to be additive. If your host has its own caching layer, the static files CacheLoop generates may simply never be served (the host cache takes priority). In that case you can disable Page Cache in settings and rely on your host's solution, while still benefiting from CacheLoop's other optimizations.

= How do I clear the cache? =

Click the **Clear Cache** button at the top of the CacheLoop settings page. The cache is also cleared automatically when you publish or edit a post or page.

= Is it compatible with Multisite? =

Single-site only in the current version. Multisite support is planned for a future release.

== Screenshots ==

1. Dashboard — at-a-glance cache status, metrics, and PageSpeed results.
2. Core Cache — page cache, browser cache, and Gzip compression settings.
3. Optimization — image lazy loading and other speed optimizations.
4. Tools — cache management and troubleshooting utilities.

== Changelog ==

= 1.0.18 =
* Added: a "Download Nginx Config" button in Browser Caching settings, shown automatically when CacheLoop detects your server isn't Apache/LiteSpeed. Generates a ready-to-use Gzip + static-asset browser-cache snippet, safe to drop straight into your existing Nginx server block, so Nginx-hosted sites no longer have to write these rules by hand.

= 1.0.17 =
* Fixed: the advanced-cache.php drop-in was only reinstalled when missing entirely, so sites that updated in-place (WordPress.org auto-update, or any path that doesn't deactivate/reactivate the plugin) kept running a stale drop-in indefinitely instead of picking up drop-in changes from the new version — with no visible error. The self-heal check now compares file content, not just presence, and reinstalls on any mismatch.

= 1.0.16 =
* Fixed: the Premium build's `is_premium` Freemius flag was hardcoded to `false` (same value as the free WordPress.org build), which hid the "Activate License" button on the Account page — clicking the only remaining button ("Sync License") just reloaded the page with no effect. `is_premium` is now detected at runtime from the presence of Premium-only code, so Premium installs correctly show the license activation flow.

= 1.0.15 =
* Fixed: "Exclude First Images from Lazy Load" was hidden behind a Pro check even though the feature itself is implemented in the free code — the setting is now available to all users.
* Fixed: REST API Cache could serve a response generated for a logged-in/privileged request to a later, unauthenticated visitor without re-checking permissions; caching is now restricted to anonymous requests, `wp/v2/settings` and `wp/v2/users` were removed from the cacheable list, and the cache key now includes the query string so different request variations of the same route no longer share one cached file.
* Fixed: the Object Cache password field was sanitized with `sanitize_text_field()`, which can strip valid password characters; it's now preserved as-is.
* Security: `wp-content/cache/cacheloop/` (which can contain the Object Cache password in `runtime-config.json`) is now protected from direct HTTP access via `.htaccess`.
* Changed: internal AJAX/admin-post action names and nonce actions now use the full `cacheloop_` prefix instead of the 2-character `cl_` prefix, for consistency with WordPress.org's minimum-prefix-length guidance.
* Fixed: deactivating could leave `WP_CACHE` enabled with the cache drop-in already removed if `wp-config.php` wasn't writable, causing "headers already sent" warnings on every page until reactivated; the drop-in is now only removed once disabling `WP_CACHE` is confirmed.

= 1.0.14 =
* Fixed: CDN Integration's inline CSS `url()` rewriting could fatal-error on any cached page (affected both the runtime rewriter and the pre-bootstrap drop-in).
* Fixed: the drop-in's runtime configuration file was being wiped by the cache flush that runs right after every settings save, silently reverting CDN rewriting, custom Cache TTL, Device-Specific Cache, and Cookie-Based Cache Bypass to their defaults.
* Fixed: the admin toolbar's "Clear All Cache" button pointed at an unregistered action and always produced a blank error page.
* Fixed: Varnish, Cloudflare, and Remove Unused CSS Safelist settings were silently discarded on every save.
* Changed: CDN Domain is now validated as a plain hostname (scheme, path, query strings, and `javascript:`/`data:` values are rejected).
* Changed: settings page scripts/styles are now properly enqueued instead of inline; internal class prefix and text domain updated for WordPress.org compliance.

= 1.0.13 =
* Fixed: a site could fatal error on every page load (front-end included) on hosts where the filesystem method resolves to non-direct (e.g. FTP) without stored credentials — the plugin's own filesystem bootstrap wasn't checking whether `WP_Filesystem()` actually connected before using it.
* Fixed: version-change cache invalidation and Image Optimization table self-heal were incorrectly skipped whenever the filesystem bootstrap above failed, instead of always running as intended.
* Changed: drop-in self-healing and wp-config.php editing now only run in wp-admin, not on every front-end request.

= 1.0.12 =
* Changed: the plugin version now shows at the top of the settings page sidebar, above "Dashboard".

= 1.0.11 =
* Changed: settings cards with extra fields (CDN, Varnish, Cloudflare, Cache Whitelist, Remove Unused CSS) now stay collapsed until their toggle is switched on.

= 1.0.10 =
* Fixed: settings cards with extra fields below the main row (CDN, Varnish, Cloudflare, Cache Whitelist/Blacklist, Cookie Bypass, Remove Unused CSS) squeezed that content onto the same row instead of stacking it below.

= 1.0.9 =
* Added: Unused CSS Removal (Pro) — strips CSS rules unused on each page from the Minify & Combine output. Conservative by design (keeps anything it can't verify safely); requires Minify & Combine CSS enabled.

= 1.0.8 =
* Added: Cloudflare Cache Purge (Pro) — mirrors CacheLoop's own purges to Cloudflare's edge via a scoped API Token, with connection test.

= 1.0.7 =
* Added: Varnish Cache Purge (Pro) — mirrors CacheLoop's own purges to an upstream Varnish server, with connection test and VCL setup snippet.

= 1.0.6 =
* Added: Original/Optimized size columns in the Optimized Images table (Pro).
* Added: click-to-preview lightbox for optimized image thumbnails (Pro).
* Added: copy button for Debug Log and Server Info panels.
* Added: estimated time and disk space needed shown before "Optimize All" starts (Pro).
* Added: one-click optimize/revert directly from the Media Library, including bulk action (Pro).
* Added: site-wide progress notice while "Optimize All" runs in the background (Pro).
* Added: hosting panel, active plugins/theme, and load average in Server Info report.
* Fixed: Image Optimization AJAX requests could fail with a raw "unknown action" error when the "Optimize on Upload" toggle was off (Pro).
* Fixed: uninstalling the plugin left generated WebP files behind instead of cleaning them up (Pro).
* Fixed: admin-page AJAX calls firing in a simultaneous burst on load, which some hosts rejected.

= 1.0.4 =
* Added: Device-specific cache (mobile/desktop split).
* Added: CDN integration with URL rewriting (drop-in + PHP fallback + inline CSS).
* Added: Cache whitelist/blacklist with wildcard pattern support.
* Added: Cookie-based cache bypass.
* Added: Debug log panel in admin with refresh/clear.
* Added: Admin toolbar buttons ("Clear All Cache", "Purge This Page").
* Added: HTTP/2 Server Push for critical CSS.
* Added: REST API cache for common endpoints.
* Added: WP-CLI commands (`wp cacheloop clear`, `status`, `preload`, `log`).
* Added: Cache metrics dashboard (file count, disk usage, last purge).
* Added: Nginx configuration generator.
* Added: Concurrent write protection via file locking.
* Added: Cache versioning with automatic flush on update.
* Fixed: Double cache serving race condition.
* Fixed: CSS minification breaking strings and url().
* Fixed: Fatal error when premium files missing.
* Fixed: extract() error on runtime config.

= 1.0.3 =
* Configurable Cache TTL (1 hour to 7 days).

== Upgrade Notice ==

= 1.0.0 =
First public release.
