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

invalidate page cache after creating new comment #13

Closed
snarfed opened this issue Jan 27, 2014 · 10 comments
Closed

invalidate page cache after creating new comment #13

snarfed opened this issue Jan 27, 2014 · 10 comments

Comments

@snarfed
Copy link
Contributor

snarfed commented Jan 27, 2014

when someone posts a new comment normally, wordpress invalidates the cached copy of the page, if it exists, so that the next request will fully re-render the page and include the new comment. it looks like wordpress-webmention doesn't do this when it stores a new comment, but it probably should.

i didn't notice this at first because i'm usually logged into my wordpress, and it skips the cache for logged in users by default and always fully renders pages.

@pfefferle
Copy link
Owner

What caching plugin do you use?

@snarfed
Copy link
Contributor Author

snarfed commented Jan 27, 2014

WP Super Cache. let me know if i can help debug. not high priority, of course!

@pfefferle
Copy link
Owner

The problem is, that I can't find a core function to clear the cache... I will have a look at what differs between my implementation and the implementation of pingbacks or classic comments... Perhaps I find the method that triggers the "clear cache"...

@pfefferle
Copy link
Owner

OK, it seems that the cache plugin is clearing the cache on the following actions:

// Coment ID is received
add_action('trackback_post', 'wp_cache_get_postid_from_comment', 99);
add_action('pingback_post', 'wp_cache_get_postid_from_comment', 99);
add_action('comment_post', 'wp_cache_get_postid_from_comment', 99);
add_action('edit_comment', 'wp_cache_get_postid_from_comment', 99);
add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment', 99, 2);

And the webmention plugin uses wp_update_comment which triggers edit_comment and wp_new_comment which triggers comment_post... And that means that it should work like it is!

Can you try adding this to your themes function.php or to the init of the webmention plugin?

if (function_exists('wp_cache_get_postid_from_comment')) {
  add_action('webmention_post', 'wp_cache_get_postid_from_comment', 99);
}

@snarfed
Copy link
Contributor Author

snarfed commented Jan 27, 2014

good idea, thanks! sadly, it didn't work, either in my theme's functions.php or in webmention.php's WebMentionPlugin.init().

@pfefferle
Copy link
Owner

Hmmm... What about pingbacks in general? Are you having the same problems with classic pingbacks? Have tried it with or without the semantic linkbacks plugin?

@snarfed
Copy link
Contributor Author

snarfed commented Jan 27, 2014

i'm not sure about classic pingbacks or without the semantic plugin, but i can definitely try later today. thanks again for investigating.

@pfefferle
Copy link
Owner

Ooops, ignore the reference... linked the wrong bug :(

@snarfed
Copy link
Contributor Author

snarfed commented Feb 3, 2014

I started looking at the WP Super Cache docs and found this in http://ocaoimh.ie/wp-super-cache-developers/ :

"Delete the cache files for a single post by using the wp_cache_post_change( $post_id ) function. It will attempt to delete every half-on cache file for that post, as well as any supercache files.
You may need to set the global variable $super_cache_enabled to make this function clean out supercached files. In requests that have GET parameters supercache is disabled so only wp-cache cache files are created, and likewise deleted."

in that last sentence, if he means query parameters for any http method, not just GET, that could explain why clearing the cache didn't work, and it gives us some ideas to try.

@snarfed
Copy link
Contributor Author

snarfed commented Feb 10, 2014

I poked at a lot of things on my local server, and then a few things on my prod server, and this went away. I have no idea why. thanks for your help anyway!

(just so the link is here, I also asked about this in the WP Super Cache forums: http://wordpress.org/support/topic/cached-pages-not-cleared-when-another-plugin-creates-comments )

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