Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have some query that brings around 50+ posts (I know it's not ideal but had to do that to build something the client asked..) and a set of loops to order them in a certain way and it looks like that this sequence is delaying parts of the rendering of the page.

I'd like to cache in a transient this entire block of rendered HTML, is that possible?

share|improve this question
1  
Keep in mind that transients are 'transient' and unless you have a persistent cache setup added ontop of wordpress, then theyre useless for anything that is only used once in a page. Transients are best used for things you need many times but should only need to be calculated once. –  Tom J Nowell Sep 12 '10 at 13:39
1  
@Tom J Nowell you are confusing transients with cache. Cache is not persistent (unless with plugin), transients are always persistent (with or without plugin). Without plugin transients are stored in database using Settings API. –  Rarst Sep 17 '10 at 4:00
    
ah, how embarassing of me lol –  Tom J Nowell Sep 17 '10 at 9:12
    
Ops, made mistake of my own - Options API, not Settings API. :) –  Rarst Sep 17 '10 at 11:08
add comment

2 Answers 2

up vote 3 down vote accepted

Transients API documentation formulates suggested usage as:

long/expensive database queries or complex processed data

Your case seems like a perfect fit for this description. On technical side you will need to concatenate your output into variable and put into transient, instead of displaying it.

share|improve this answer
add comment

If I were to implement this today, my preference would be the memcache object cache, storing the data using wp_cache_set(), possibly updating the data using WP_Cron rather than during page load.

Just how many kilobytes are we talking about?

share|improve this answer
    
I'm guessing pretty low (less then 10).. the issue is that I have quite a bit looping/juggling to sort and display the way I need to. memcache (with all its surrounding) looks a bit to much. –  Amit Sep 7 '10 at 21:19
1  
Transients automatically make use of object cache if such plugin is active. There is no need to use wp_cache_set() if transient mechanics are more fitting for the task. –  Rarst Sep 12 '10 at 13:15
    
Yeah, my only question would have been the amount of data you can reasonably store in a transient. It's a LONGTEXT, so... plenty. :) –  Annika Backstrom Sep 12 '10 at 13:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.