0

WordPress places JSON oembed links in the page header, such as in this example:

<head>
...
<link rel='https://api.w.org/' href='http://example.com/wp-json/' />
<link rel="alternate" type="application/json+oembed" href="http://example.com/wp-json/oembed/1.0/embed?url=..." />
<link rel="alternate" type="text/xml+oembed" href="http://example.com/wp-json/oembed/1.0/embed?url=..." />
</head>

I never saw an issue here until recently, when I began using Mastodon as an additional social media outlet. When I share my WP blog posts on Mastodon, I noticed my server gets hammered -- floored -- for about 4-5 minutes. I saw load going over 100, with a similar number of httpd processes kicking off on my server, and looking at the logs I realized that hundreds of Mastodon instances (servers) were simultaneously hitting my blog, GETing the URL provided in the above code. (Mastodon is a distributed network and, as such, it's not a grab-it-once affair -- every server grabs it on its own.) This problem is only going to get worse as more instances pop up.

I am aware that I can disable these links in the header, but they provide information about that post that I would like the Masto instances to have. Is anyone aware of a way to cache these so that whenever a blog link of mine is shared, my server is not rendered incapacitated for a period of time?

I use W3 Supercache and am trying the WP REST Cache plugin, but these are not helping. In the case of the latter, it may be that (despite being a web developer), I'm missing something as far as it being able to handle this.

Surely I'm not the only person to have felt this pain in the past few months. Thanks.

bp

1 Answer 1

0

Some hosts will use a page cache for API routes to deal with this kind of problem. My initial thought would be to look at something like Cloudflare (they have some WordPress presets too) that would allow you to set up this kind of page cache for these API routes.

Interested to know how you get on as I've definitely seen similar issues with my site soon after sharing it on Mastodon!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.