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:

  1. Add the following code using one of the methods described in our Add Code Snippets article, or using an MU Plugin:
  2. 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;
  3. Deactivate and reactivate WP Rocket plugin for the change to start working.
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.