When should I be using the Transients API?

Posted by Prem Tiwari | Updated on

Transients are great when you’re doing complex queries in your themes and plugins. I tend to use transients for things like menus and showing other things like Tweets from Twitter in a sidebar for example. I wouldn’t use them for absolutely everything more-so just temporary pieces of data that can be cached.

Keep in mind that if you use something like Memcached with transients, then you will notice a massive performance gain. The rule with transients is to not use them for data that should not expire as they’re really only for temporary data and keep in mind transients are not always stored in the database.

Some uses for transients:

  • Complex and custom database queries
  • WordPress navigation menus
  • Sidebar widgets that display info like; tweets, a list of recent site visitors or a Flickr photo stream
  • Caching tag clouds

If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers