Enable cache for WhatsApp agent
The WhatsApp user agent is automatically excluded from being served cache files to prevent potential incompatibilities that could occur: for example, when a post/page is shared on WhatsApp.
If you want to serve cached pages to the WhatsApp bot instead ( not recommended), then you can proceed with the following steps:
- Add the following code using one of the methods described in our Add Code Snippets article, or using an MU Plugin:
- Deactivate and reactivate WP Rocket plugin for the change to start working.
add_filter( 'rocket_cache_reject_ua', 'wprocket_remove_whatsapp_ua' ); function wprocket_remove_whatsapp_ua( $ua ) { if ( in_array( 'WhatsApp', $ua ) ) { $ua = array_flip( $ua ); unset( $ua[ 'WhatsApp' ] ); $ua = array_flip( $ua ); } return $ua; }