Using Contact Form 7 with WP Rocket

This article contains information about using the Contact Form 7 plugin along with WP Rocket.

Automatic optimization of assets

WP Rocket will load the JavaScript and CSS assets of the Contact Form 7 plugin only in pages that include forms.

And, for pages that don't have a form, none of those assets will be loaded.

This is an automatic optimization applied by WP Rocket when the Contact Form 7 plugin (versions 5.8.1 and newer) is detected on a site.

Known issues

If Contact Form 7 has stopped working on your site, please check the following:

  • Set your Cache Lifespan to 8 hours - Contact Form 7 uses a nonce which requires the cache be refreshed periodically. 
  • If you have any other layer of caching on your server, you may need to exclude the contact form URL from it, due to the nonce issue mentioned above.

How to deactivate this optimization

If you're having issues, and need to deactivate this feature, you can install the following helper plugin:

📥   Download (.zip):  WP Rocket | Disable Contact Form 7 Optimization
Developers: You can find the code for this plugin on GitHub.

Alternatively, you can use the following snippet:

add_filter( 'rocket_thirdparty_load', function( $status, $thirdparty ) {
if ( 'contact-form-7' !== $thirdparty ) {
    return $status;
}
return false;
}, 10, 2 );

You can add the above snippet as shown here.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.