Slow WP Performance on WP-Discourse API Endpoint "discourse-comments"

Hello, All! My first post here.

I am currently working on integrating a 10+ old WP site with Discourse. I have gone to great lengths to ensure that the WP instance is clean and running well with 10 years of data. After installing the WP-Discourse plugin and getting things setup (properly, I hope), the server kept getting slogged. It is hosted on Cloudways, so I asked those engineers if I was missing anything.

They responded that /wp-json/wp-discourse/v1/discourse-comments?post_id=undefined was causing a huge performance hit. I’m not sure exactly why post_id’s would be undefined.

The following picture is a list of url requests within a 24 hour period.

Any thoughts on how I can fix this error? I have searched a lot for a good answer to this. Just making sure I get some insight before deep diving into the nuances of the code.

1 Like

Sorry about the delayed response to this - I’ve been on holidays.

The route that is getting hit at /wp-json/wp-discourse/v1/discourse-comments is only available when the Load Comments With Ajax option is enabled. That option is found on the WP Discourse Commenting settings tab. Can you try disabling that setting?

1 Like

No worries, @simon - I hope your travels went well!

I’ll disable that setting this evening and post back with results soon!

Thank you!

Disabling that setting should take care of the issue with requests being made to /wp-json/wp-discourse/v1/discourse-comments. Let me know if it doesn’t.

I’m unsure why requests to that route were being sent with the post_id=undefined parameter. The request should be using the id of the current post. If the post_id parameter is set to undefined then the function that handles that route will return an empty string. Enabling the Load Comments With Ajax option will result in more requests being made to your server than if the option is not enabled, so unless you are running into issues with comments not being updated due to caching, it is best to leave that option disabled.

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.