Caching Plugins & Cache Servers Integration

Caching plugins or server-side caching could cause potential conflicts with our Password Protect WordPress (PPWP) plugins. In this article, we will show you how to make the top caching plugins and servers work properly with our PPWP plugins – both Free and Pro version.

Cache Servers

If you are using caching servers such as Cloudfare, LiteSpeed, or Sucuri, you might come across the issue where you have to enter passwords twice to unlock the content. In this case, you can exclude our cookies or protected page URLs from your caching servers.

If you are to password protect your entire site, you should “Purge all your site cache” first or simply deactivate these caching plugins for our site-wide protection feature to work properly. You shouldn’t cache a protected site in the first place, should you?

Simply add the following cookies to the Exclude Cache option in your hosting server’s account.

For PPWP Free version:

pda_protect_password
wp-postpass-role_*

For PPWP Pro version:

pda_protect_password
wp-goldpass-pagepost_*

Exclude password protected page URLs

Since our cookie exists on every page of your site, excluding cookies from caching servers will prevent your entire site from being cached. In case you just protect some pages in your site, the better solution is excluding your password protected page URLs only.

Sucuri Firewall

PPWP Pro works well with Sucuri Security Firewall. However, when enabling its caching, users may need to enter the password twice in order to access the protected content.

Here’s how you can fix it with 2 simple steps:

  1. Under Sucuri Firewall dashboard, click on Performance – Advanced Settings.
  2. Under Non-Cache URLs, exclude your password protected pages from the Firewall cache as follows:

That’s all you have to do. Now your password protected pages should work properly without you having to enter your password twice.

GoDaddy

In order to sitewide protection feature to work properly with Godaddy server cache, add the code snippet below to your (child) theme’s functions.php file.

For PPWP Pro version:

function ppwp_generate_param_redirect( $bypass ) {
	if ( ! empty( $_POST ) ) {
		return $bypass;
	}

	$ip_hash   = substr( md5( microtime() . rand() ), 0, 12 );
	$query_key = 'vp';
	if ( ! isset( $_GET[ $query_key ] ) ) {
		global $wp;
		$redirect_url = trailingslashit( home_url( $wp->request ) );
		if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
			$redirect_url = add_query_arg( wp_unslash( $_SERVER['QUERY_STRING'] ), '', $redirect_url );
		}
		if ( ! get_option( 'permalink_structure' ) ) {
			$redirect_url = add_query_arg( $wp->query_string, '', $redirect_url );
		}
		$redirect_url = add_query_arg( $query_key, $ip_hash, remove_query_arg( $query_key, $redirect_url ) );
		wp_safe_redirect( $redirect_url );
		exit;
	}

	return $bypass;
}

add_filter( 'ppwp_sitewide_handle_before_valid_password', 'ppwp_generate_param_redirect' );

Caching Plugins

Our PPWP Free and Pro plugins work perfectly with the top WordPress caching plugins automatically without any extra configurations.

  • W3 Total Cache
  • WP Super Cache
  • WP Fastest Cace
Lasted updated on August 28, 2020