How to Clear oEmbed Cache in WordPress?

While publishing content on your site, you might want to embed some YouTube videos, tweets, or even Google Maps to make the article unique and helpful for your visitors. In most cases, your server will fetch the embedded content and store it as an oEmbed cache. This is not the basic WordPress caching system but like any other cache, it’s important to clear it regularly. That’s why in this guide, we are going to show you how to clear the oEmbed cache in WordPress.

What’s the oEmbed cache?

When you paste a YouTube video URL on your site or use the Gutenberg blocks, WordPress checks the destination URL and searches for the content that needs to be embedded. So, when a visitor goes to the page where you have embedded the video, your server will automatically generate cached files in your website’s database.

This process is possible thanks to the oEmbed cache. It allows a website to display any embedded content without the need to parse the source of the content.

Although you can clear your site’s cache by using any caching plugin, you won’t be able to remove the oEmbed cache just like that.

Why clear the WordPress oEmbed cache?

Your web server will store the cache for some time. But, when you need to fetch the updated content, you might want to clear your existing oEmbed cache and generate new ones.

For example, let’s say you have embedded several YouTube videos on your site. In some cases, later on, the YouTube channel owner may update the thumbnail of the video or make some changes to it. However, those changes won’t display on your site if you use the old cache.

When you embed the video for the first time, your server fetches all this information from the third-party server, caches the content, and renders it in the frontend. So, clearing the cache will help you fetch the recently updated content from the third-party server. On the other hand, if the code generated through the oEmbed is damaged and you couldn’t see anything in the frontend, it’s a good idea to clear the cache too.

So now that we better understand the topic, let’s see how to clear the oEmbed cache in WordPress.

How to clear the oEmbed cache in WordPress?

Clearing the oEmbed cache in WordPress requires you to follow a series of steps. Here we’ll describe the process step by step so it’s easy to follow even for beginners. Please note that you’ll need access to the MySQL database server as you’ll make some customizations there.

NOTE: Since you are going to make some changes to your site’s tables, for security reasons, we recommend you generate a complete backup of your website before starting the process. If you’re not sure how to do it, check out our guide on how to back up a site.

Clear oEmbed cache from cPanel

    1. First, log in to your website’s cPanel, and go to PHPMyAdmin.
      A) If you are using a shared hosting plan, you will see it right there under the Databases section.B) On the other hand, if you are using a premium managed WordPress hosting like Kinsta, you will find PHPMyAdmin under your site info section.

      If you can’t find the PHPMyAdmin tab, feel free to contact your web hosting provider for help and support.

    2. Once you open PHPMyAdmin, you will see a long list of tables. Select the WordPress Post Meta table from there. By default, the name of this table is wp_postmeta, unless you have previously made any modifications to the table prefix. In our case, we are using a custom table prefix for better security.
      Clear oEmbed Cache in WordPress - WP postmeta
    3. After you open the wp_postmeta table, on the top of the screen you will see some tools like:
        1. Browse.
        2. Structure.
        3. SQL.
        4. Search.
        5. Insert.
        6. Export.
        7. And others.

      Clear oEmbed Cache in WordPress - WP postmeta options

    4. Go to the Search tab and search for the oEmbed tables. Set the meta_key as LIKE %…% from the dropdown. And in the Value field, set the value as _oembed. After that, click the Go button.
    5. On the next screen, you will be able to see all the oEmbed meta keys.
    6. Now it’s time to clear the oEmbed cache of your WordPress site. Clearing the cache is pretty simple. All you need to do is, click the Check All button, and then press Delete.Clear oEmbed Cache in WordPress - MenuThat’s it! You have successfully cleared the oEmbed cache from your WordPress site.

So, next time a visitor browses through the pages that have embedded videos or images, your server will automatically fetch the new, updated cache from the third-party server. This way, the oEmbed cache gets restored automatically, you don’t need to do anything.

Conclusion

So this is how you can clear the WordPress oEmbed cache in WordPress. If you have followed the steps, you will be able to remove the oEmbed cache in less than 5 minutes. Always remember to create a complete backup of your site before proceeding. As we mentioned at the beginning, this method works for embedded images, videos, and also if you have Google Maps on your site.

If this article was helpful, please share it on social media. For more useful guides, check out our blog section.

Do you know any other simple fix for this problem? If you have something, let us know in the comments section below!