Cacheing – transient html

Why use transients ?

To cache the html:

The cacheing process is sql intensive.  It is the way it is primarily because of the way that various third party plugins create user data.  A later version (maybe version 4.0 upwards) will have improved method for those who have standard wp user meta data – yay!   That’s the data not the html.

Querying the cache may also place a load (depending how weird (non wp) your data is and on your report settings).

WordPress offers transients for short term caching. The amr users plugin uses the transients feature to cache the html for the user lists.  If you have a lot of querying activity where people are just browsing the first page, stored  html may reduce the query load on the database.  The transient default expiry setting is 60 seconds.  Later plugin versions may allow you to set this value.

Stored html not used:

Stored transient html is not used (cannot be used) when filtering or sorting or  perform some action on the stored cache data.

It is also not used (obviously) when the cached has just been rebuilt.

Stored html may be used:

The first view after cacheing may store the html in a transient.  If someone requests that self same page before transient expiry, then the stored html may be used.

Arghh, this makes testing hard – how do I know if a transient is used?

Easy.  If you are a logged in admin user when you view a list it will show a subtle exclamation mark. Hopefully not so subtle that you miss it!

Transient html exclamation mark for admin users

Transient html exclamation mark for admin users

To test this,

  • login as admin
  • view the list
  • now refresh the page
  • Voila… now hover over the exclamation mark
Hover text on transient exclamation mark

Hover text on exclamation mark

Refreshing the html, from the cached data

OMG how hard is testing when you don’t know whether the data is the latest or not ?  Tell me about it ! (no really don’t, I know. I’m pedantic, I like to test and check every step of the way and know exactly what’s going on, so of course there is a way….)

Now click on that exclamation mark – magic happens.  It is actually a  link with a little refresh query parameter added:


If you have debug enabled, you may see a little debug message telling you what’s happening:

Debug message

Debug message

Don’t panic – the message only shows if you have WP_Debug enabled and are a logged in admin.

Hmm interesting, on demand refresh of the cached data huh?