# Cache oEmbed Results Longer

> Keeps embedded content like videos and social posts cached for 30 days instead of re-fetching it from the provider every day.

- Type: PHP
- Runs: Run everywhere
- Category: [Performance](https://wpide.com/library/category/performance/)
- Tags: performance, embeds, caching
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/cache-oembed-longer/

## Code

```php
// How long embed data stays cached.
$wpide_oembed_ttl = 30 * DAY_IN_SECONDS;

add_filter( 'oembed_ttl', function () use ( $wpide_oembed_ttl ) {
    return $wpide_oembed_ttl;
} );
```

## Notes

Changes to an embedded item (a renamed video, for example) take longer to show.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Cache oEmbed Results Longer" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
