How can I stop my WordPress database collecting transients such as RSS feeds in wp_options table?

but I’d like to know if there is a way to prevent them from getting into my database in the first place.

The only way to prevent expired transients ever being a thing is to never use them to begin with.

When you create a transient an option is created with a particular name. Eventually that transients expiration date comes and it needs cleaning up, this can be automated and WordPress does this automatically. Your situation happens because that automation is either disabled or unable to run.

Sadly, what you’re asking for is the very thing you’re trying to avoid, a clean up cron job of some sort.

As for RSS feeds, you wouldn’t want this. Not caching the result would lead to major performance losses. HTTP requests are some of the slowest and most expensive things you can do in WordPress. This can also have significant knock on effects on popular plugins that fetch news and other RSS feeds, as well as RSS widgets and RSS blocks.


As an aside, if you have an object cache, WP will try to use it instead for transient storage, e.g. Redis or memcached. Redis/etc will auto-cleanup, and has its own expired garbage collection processes too. This becomes highly dependent on your server and software though, and you’re essentially trading one set of problems for another. You should get a persistent object cache if you can, but because it’s a big performance boost, not for transient cleanup.