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 a big site for a client, and as it is a really customized wordpress installation with lots of extensions on functionality, I can't use the caching plugins.

To improve the performance, I built a lot of the Site using transients (for example the navigation, the google maps with all the markers etc.), and leave the dynamic content dynamic.

The problem here is if I change anything, I have to manually delete the specific transient to see the current result. The site shows different menus and googlemaps when entered from a different channel, so I have like ten transients for each area.

Would you create a function where I delete those all at once (with a listing of the names of the transient), or is it okay to just delete all the transients on the site?

It's not really that urgent, but for future ddevelopment I would like to know if you had any problems with stuff like that, and how you manage all your transients.

Cheers, fischi

share|improve this question

3 Answers 3

up vote 5 down vote accepted

For development I would advise to always work with WP_DEBUG set to true and do the following:

$key = 'transient_key';
if( !WP_DEBUG && ( false !== ($transient = get_transient($key)) ){

   /* Generate transient manually */
   $expiration = 24*60*60;//How long to keep for
   set_transient($key,$transient, $expiration);
}

In general - it should be fine deleting transients, as they should never be assumed to be in the database.

share|improve this answer
    
thanks @stephen, I used this solution in the development phase, but cleared it out at the refactoring phase before going life. should not have done that ;) but in your experience, have you evver had any trouble with deleting transients manually? –  fischi Nov 21 '12 at 16:56
    
:) thanks for the info on deleting transients. i thought something like that, but was not totally sure. –  fischi Nov 21 '12 at 16:59
1  
No, I've never had trouble deleting transients manually - except in getting fed up with it and using this approach :). –  Stephen Harris Nov 21 '12 at 17:14

You should be hooking the various actions that run when things are updated to clear out and refresh transients. For example, when the nav menu is updated, the wp_update_nav_menu action is fired, hook a function to that to refresh your nav menu transient.

share|improve this answer
    
thanks @Milo, this one is a good idea, but not usable for me, as the transients do not just affect the menu. there is a lot of content (points of interests on a map) added all the time, and the site is quite busy - so i build for example the list of newest POIs just once an hour, not just on the wp_update_nav_menu –  fischi Nov 21 '12 at 16:58
    
that was just one example, refresh each transient on whatever action it's tied to –  Milo Nov 21 '12 at 17:05
    
yeah, you're right here. not all my transients are tied to an action, though. some of them are used right in the template files (when i create large lists), and contain the actual html, each one lasting one hour. for the transients that are set for a long life, like the one you mentioned, I use your method :) –  fischi Nov 21 '12 at 17:09

Would it not be better to do your development on a development environment so that the need to see your changes as they are made doesn't impact the public site?

Using this approach you could then deploy/promote to production and flush the transients at a low traffic time with minimal impact to site performance and user experience.

share|improve this answer
    
yeah, would be better of course - but i started the project a few weeks after i started my business, and learned a lot since then. i am just building up my complete infrastructure - and i am planning on developing the custom themes and plugins on my server, and as soon as they are finished deploy an update to the sites with the wordpress update function. this was not the best of methods i chose there, i admit. –  fischi Nov 21 '12 at 17:04
    
I think we've all been there and done that at one time or another. –  Stephen Nov 21 '12 at 17:05

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.