Cache Compatibility
AffLoc is specifically designed to work with all caching plugins. Here’s why.
The Problem with Server-Side Geolocation
Many link localization plugins modify the HTML on the server — rendering different HTML for different countries. This completely breaks page caching because a cached page shows the same HTML to everyone.
AffLoc’s Approach: Client-Side Swap
AffLoc takes a different approach:
- Server renders a static HTML page with the default link. This HTML is identical for every visitor and can be fully cached.
- A small JavaScript file (~5KB) runs after page load.
- JavaScript detects the country (via cached localStorage or REST API call).
- JavaScript swaps the link href to the country-specific URL.
Because the HTML itself never changes, your caching plugin caches one version for everyone. The link swap happens instantly in the browser.
Tested Caching Plugins
- WP Rocket
- W3 Total Cache
- LiteSpeed Cache
- WP Super Cache
- Autoptimize
- Cloudflare APO
Performance Notes
- The frontend script only loads on pages that contain the
shortcode. - Country detection is cached in the browser for 24 hours.
- After the first visit, link swapping is instantaneous with no API calls.