Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Purge VIP varnish cache if available #677

Open
WPprodigy opened this issue Dec 9, 2021 · 1 comment
Open

Purge VIP varnish cache if available #677

WPprodigy opened this issue Dec 9, 2021 · 1 comment

Comments

@WPprodigy
Copy link

Opening this to track this closed PR: Automattic/vip-go-mu-plugins#984

If still desired/needed, the cache-purging functionality can be added to this plugin. Perhaps here: https://github.com/Automattic/liveblog/blob/25bc1f0f2e6b53c6ecd1ccec080600e01f54abd8/wpcom-helper.php

@WPprodigy
Copy link
Author

/**
 * Purge the Varnish cache for a liveblog on each new entry.
 *
 * Ensures that a Liveblog page isn't cached with stale meta data during an
 * active liveblog.
 *
 * @param  int $comment_id ID of the comment for this new entry.
 * @param  int $post_id    ID for this liveblog post.
 */
function wpcom_vip_liveblog_purge_on_new_entries( int $comment_id, int $post_id ){

	if ( ! function_exists( 'wpcom_vip_purge_edge_cache_for_url' ) ) {
		return;
	}

	// Get the URL for this Liveblog post.
	$permalink = get_permalink( absint( $post_id ) );
	if ( ! $permalink ) {
		return;
	}

	// Purge the Varnish cache for the liveblog post so that new loads of the
	// post include the newest entries.
	wpcom_vip_purge_edge_cache_for_url( $permalink );

}
add_action( 'liveblog_insert_entry', 'wpcom_vip_liveblog_purge_on_new_entries', 10, 2 );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant