WhoKnew Views™ | CDN Integration

Skip to main content
Table of Contents
Print

How WhoKnew Views™ works with CDNs, edge caching, and content delivery networks

Content Delivery Networks (CDNs) are essential for fast WooCommerce stores, serving assets from edge servers closest to your visitors. WhoKnew Views™ is designed to work seamlessly with any CDN—including Cloudflare, Fastly, AWS CloudFront, KeyCDN, and others—without any special configuration.

🌐 CDN-Compatible by Design

WhoKnew Views™ uses server-side PHP execution for view tracking—not JavaScript. This means view counting happens at the origin server, completely bypassing CDN caching.

✅

Server-Side Tracking

PHP execution at origin

✅

Cookie Verification

Works through edge caching

✅

Real IP Detection

Cloudflare headers supported

✅

Asset Fallbacks

CDN backup for Chart.js

🔍 Smart IP Detection for CDNs

When a CDN or proxy sits between your visitor and your server, the visitor’s real IP address is typically forwarded in HTTP headers. WhoKnew Views™ automatically checks these headers in priority order:

// IP Detection Priority Order (ip-whitelist-check.php)

$headers

= array(
‘HTTP_CF_CONNECTING_IP’, // Cloudflare
‘HTTP_X_REAL_IP’, // Nginx proxy
‘HTTP_X_FORWARDED_FOR’, // Standard forwarded
‘HTTP_CLIENT_IP’, // Some proxies
‘REMOTE_ADDR’ // Direct connection (fallback)
);

💡 Cloudflare Users:The plugin automatically reads HTTP_CF_CONNECTING_IP first, ensuring accurate IP detection and whitelist matching even when Cloudflare proxies your traffic.

📦 CDN Fallbacks for Chart.js

WhoKnew Views™ Pro bundles Chart.js locally for the Insights dashboard. However, the plugin includes automatic CDN fallbacks in case local files fail to load:

LibraryPrimary SourceFallback CDN
Chart.jsassets/js/chart.umd.min.jsjsdelivr CDN
Date Adapterassets/js/chartjs-adapter-date-fns.bundle.min.jsjsdelivr CDN

This “local-first, CDN-fallback” approach means:

  • 📁 Normal operation: Assets load from your server (benefiting from your CDN cache)
  • 🔄 Fallback mode: If local files fail, Chart.js loads directly from jsdelivr
  • 🎯 Result: Analytics charts always work, regardless of asset caching issues

🍪 Cookie Tracking Through CDNs

View tracking cookies work perfectly with CDNs because:

🔒

Server-Side Cookies

PHP sets cookies server-side using setcookie(), not JavaScript. This happens at the origin server, unaffected by CDN caching.

📤

HttpOnly Flag

Cookies are set with httponly: true, meaning they travel with every request to your origin—CDNs pass them through.

⏱️

Proper Expiration

Cookies expire based on your View Window and Refresh Cooldown settings, handled independently of CDN cache TTLs.

⚙️ CDN Configuration Tips

While WhoKnew Views™ works out of the box, here are recommendations for optimal performance:

📋 Recommended CDN Settings

1. Don’t Cache WooCommerce Product Pages

Most CDNs automatically bypass cache for pages with cookies (like WooCommerce cart/checkout). Product pages should also bypass to ensure accurate view counting.

2. Cache Plugin Assets

Static files in /wp-content/plugins/whoknew-views*/assets/ can be cached aggressively. These include CSS, JS, images, and font files.

3. Keep Real IP Headers Enabled

If using Cloudflare, ensure “True-Client-IP” or “CF-Connecting-IP” header is enabled in your Cloudflare settings (enabled by default).

📊 CDN Caching & View Accuracy

Understanding how CDN caching affects view tracking:

ScenarioView Tracked?Why
CDN Cache MISS (first request)✅ YesRequest reaches origin, PHP executes
CDN Cache HIT (cached page)❌ NoPage served from edge, no PHP execution
Visitor has cookie (any request)✅ Reaches OriginMost CDNs bypass cache for cookie requests
WooCommerce product page✅ YesDynamic pages typically bypass cache

💡 Pro Tip:For maximum view tracking accuracy, configure your CDN to bypass cache for WooCommerce product pages (/product/*). Most caching plugins and CDNs handle this automatically.

🚀 Tested CDN Compatibility

☁️

Cloudflare

✅ Fully Compatible

📦

AWS CloudFront

✅ Fully Compatible

⚡

Fastly

✅ Fully Compatible

🔑

KeyCDN

✅ Fully Compatible

🐰

BunnyCDN

✅ Fully Compatible

🌐

StackPath

✅ Fully Compatible

✨ Zero Configuration Required

WhoKnew Views™ is designed to work seamlessly with any CDN without special configuration. The plugin’s server-side tracking, smart IP detection, and cookie-based verification ensure accurate view counts regardless of your caching setup. 🔧 Technical Reference

IP Detection Functionwkv_get_client_ip()
Cloudflare HeaderHTTP_CF_CONNECTING_IP
Chart.js CDN Fallbackcdn.jsdelivr.net/npm/chart.js@4.4.0
File Locationincludes/ip-whitelist-check.php

Share