Counting Modes Explained
Overview
View Counter WP offers three ways to record a page view. The right choice depends on your hosting and caching setup. All three modes produce identical data — the difference is only in how the count is triggered.
PHP Mode (Server-Side)
The simplest mode. When WordPress renders a page, the view is counted immediately in PHP before the HTML is sent to the browser.
Pros:
- Zero front-end overhead (no JavaScript, no extra request)
- Instant, synchronous counting
- Works perfectly on uncached sites
Cons:
- Does NOT work with full-page caching — cached pages bypass PHP entirely
Use when: Your site doesn’t use page caching, or you’re on managed hosting that handles cache invalidation.
JavaScript Mode (AJAX)
After the page loads in the browser, a small JavaScript snippet fires an AJAX request to wp-admin/admin-ajax.php to record the view.
Pros:
- Works behind all page caching solutions
- Small, non-blocking async request
- Proven WordPress AJAX pattern
Cons:
- One additional HTTP request per page view
- Requires JavaScript to be enabled
Use when: You use WP Super Cache, W3 Total Cache, WP Rocket, or similar server-side caching.
REST API Mode
Similar to JavaScript mode, but sends the request to the WordPress REST API endpoint (/wp-json/view-counter/v1/track) instead of admin-ajax.
Pros:
- Works behind edge caching (Cloudflare, LiteSpeed, Varnish)
- Cleaner, lighter endpoint than admin-ajax
- Modern WordPress pattern
Cons:
- One additional HTTP request per page view
- REST API must be accessible (some security plugins restrict it)
Use when: You use Cloudflare APO, LiteSpeed Enterprise cache, or other edge/CDN-level caching.
If you’re not sure which to pick, start with JavaScript mode — it works reliably in virtually all WordPress hosting environments.