I have fragment caching implemented in a page. I've got the codes from https://css-tricks.com/wordpress-fragment-caching-revisited/.
Which goes like this:
function fragment_cache($key, $ttl, $function) {
if ( is_user_logged_in() ) {
call_user_func($function);
return;
}
$key = apply_filters('fragment_cache_prefix','fragment_cache_').$key;
$output = get_transient($key);
if ( empty($output) ) {
ob_start();
call_user_func($function);
$output = ob_get_clean();
set_transient($key, $output, $ttl);
}
echo $output;
}
And I want to clear the transient set when a post is added. How can i do that?
taxonomy.php
that loads all the post under it. The looping was within the fragment cache. I just thought that if i add new post under that taxonomy, it won't show the new post because the time has not yet elapse. Is that how it works right? or i am mistaken? @N00b Help mesave_post
anddelete_post
hooks IMO.