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

When clearing by Post ID, it invalidates the whole CDN #84

Open
barrychapman opened this issue Nov 19, 2021 · 3 comments
Open

When clearing by Post ID, it invalidates the whole CDN #84

barrychapman opened this issue Nov 19, 2021 · 3 comments

Comments

@barrychapman
Copy link

Flushing by post ID 48272 this is what was logged in CloudFront console:

image

Why isn't it clearing by permalink path? Why is it clearing the whole root node of the CDN and (not even) the child pages (/*) ?

@barrychapman
Copy link
Author

I resolved this by modifying Post_Service.php:

public function list_posts_by_ids( $post_ids ) {
		$query = new \WP_Query(
			array(
				'post__in' => $post_ids,
				'post_type' => 'any'               // <--- added this filter for WP_Query
			)
		);
		$posts = $query->get_posts();
		
		
		
		wp_reset_postdata();
		return $posts;
	}

@rghica
Copy link

rghica commented Mar 13, 2023

I too am finding that the entire distribution is being invalidated when a single post id is entered into the "Flush Cache by Post ids"

The suggested additional line caused an error with Cloudfront "InvalidArgument (client): Your request contains one or more invalid invalidation paths."

@rghica
Copy link

rghica commented Mar 13, 2023

There is a similar error when updating the post ... so I'm wondering if the problem is due to the permalink structure -- I'm using a slug / post name rather than the post id ... could that be the issue?

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

2 participants