Allowing Caching for WPML and WCML on BionicWP
Overview
If you're using the WooCommerce Multilingual & Multicurrency (WCML) plugin along with WPML on BionicWP, you may experience caching issues. This is due to specific cookies that interfere with Batcache and Edge Cache, causing poor performance or inconsistent behavior.
Cookies like:
wcml_client_currencywcml_client_currency_languagewcml_client_countrywp-wpml_current_language
are essential for multilingual and multicurrency functionality but can prevent proper caching. To fix this, you’ll need to customize Batcache so it recognizes these cookies properly.
How It Works
BionicWP’s caching system (Batcache and Edge Cache) avoids caching when certain cookies are set, often assuming they indicate a dynamic or personalized experience. However, for sites using WCML and WPML, these cookies are common and necessary.
By telling Batcache to allow caching while treating these cookies appropriately, you maintain both performance and functionality.
Step-by-Step Instructions
1. Disable Language Filtering for AJAX Operations (WPML)
This step removes one of the problematic cookies: wp-wpml_current_language.
In your WordPress dashboard, go to
WPML → Languages.Scroll to Language filtering for AJAX operations.
Uncheck “Store a language cookie to support language filtering for AJAX”.
Save the changes.
2. Choose Your Batcache Customization Method
You have two options:
Option 1: Modify wp-config.php Directly
Connect to your site via SFTP or SSH.
Open the
wp-config.phpfile in your/htdocsroot directory.Just above this line:
/* That's all, stop editing! Happy blogging. */Paste the following:
// Batcache Customizations global $batcache; $new_noskip = array( 'wcml_client_currency', 'wcml_client_currency_language', 'wcml_client_country', 'wp-wpml_current_language' ); if (is_object($batcache)) { $batcache->noskip_cookies = isset($batcache->noskip_cookies) && is_array($batcache->noskip_cookies) ? array_unique(array_merge($batcache->noskip_cookies, $new_noskip)) : $new_noskip; $batcache->unique = isset($batcache->unique) && is_array($batcache->unique) ? $batcache->unique : array(); foreach ($new_noskip as $cookie) { $batcache->unique[$cookie] = isset($_COOKIE[$cookie]) ? $_COOKIE[$cookie] : ''; } } elseif (is_array($batcache)) { $batcache['noskip_cookies'] = isset($batcache['noskip_cookies']) && is_array($batcache['noskip_cookies']) ? array_unique(array_merge($batcache['noskip_cookies'], $new_noskip)) : $new_noskip; $batcache['unique'] = isset($batcache['unique']) && is_array($batcache['unique']) ? $batcache['unique'] : array(); foreach ($new_noskip as $cookie) { $batcache['unique'][$cookie] = isset($_COOKIE[$cookie]) ? $_COOKIE[$cookie] : ''; } } // End Batcache Customizations
Option 2: Use a Separate skip-cache.php File
In your
/wp-contentdirectory, create a new file calledskip-cache.php.Add the following code:
<?php /** * Batcache Customizations for WCML/WPML */ global $batcache; $new_noskip = array( 'wcml_client_currency', 'wcml_client_currency_language', 'wcml_client_country', 'wp-wpml_current_language' ); if (is_object($batcache)) { $batcache->noskip_cookies = isset($batcache->noskip_cookies) && is_array($batcache->noskip_cookies) ? array_unique(array_merge($batcache->noskip_cookies, $new_noskip)) : $new_noskip; $batcache->unique = isset($batcache->unique) && is_array($batcache->unique) ? $batcache->unique : array(); foreach ($new_noskip as $cookie) { $batcache->unique[$cookie] = isset($_COOKIE[$cookie]) ? $_COOKIE[$cookie] : ''; } } elseif (is_array($batcache)) { $batcache['noskip_cookies'] = isset($batcache['noskip_cookies']) && is_array($batcache['noskip_cookies']) ? array_unique(array_merge($batcache['noskip_cookies'], $new_noskip)) : $new_noskip; $batcache['unique'] = isset($batcache['unique']) && is_array($batcache['unique']) ? $batcache['unique'] : array(); foreach ($new_noskip as $cookie) { $batcache['unique'][$cookie] = isset($_COOKIE[$cookie]) ? $_COOKIE[$cookie] : ''; } }Then, in your
wp-config.php, add this line above the "Happy blogging" comment:include_once __DIR__ . '/wp-content/skip-cache.php';
3. Clear Your Site’s Cache
Once your code changes are done, clear your site’s cache to ensure updates take effect. You can follow BionicWP’s guide on how to clear cache in WordPress if needed.
4. Confirm Caching Is Working
Use your browser or terminal to confirm Batcache is working:
Browser Method:
Open your site.
Right-click > Inspect > Network tab.
Refresh the page.
Click the main domain request and check “Headers”.
Look for:
X-Ac: lhr _atomic_ams HIT
x-nananana: Batcache-SetTerminal Method:
Run this:
curl -I https://yourdomain.comCheck for the same headers.
Pro Tip
To maintain performance and multilingual functionality, keep these customizations in place during plugin updates or environment changes. Consider version controlling wp-config.php and skip-cache.php if you're using Git, so nothing gets lost during deployments.
