using cache on the homepage 10 records (and a minor SAVEDQUERIES query)
-
(i’m on 2.0.4)
when i got savedqueries working and got to see where all the time is being spent on my homepage, the determining step was selecting the recent 10 posts. it varied from .2s to close on 2s at some points. everything else rarely added .3s more.
Now perhaps I could look into just why that query is taking so long, but having just learned how to use the WP cache I thought I’d try using it instead. what i ended up doing was hacking get_posts in classes.php with something like
if ($this->is_home) { try_using_special_cache_code } else {$this->posts = $wpdb->get_results($this->request);}
and using an add_action(‘publish_post’… to clear the cache when a new post is written.
Now it works a treat – the front page rarely loads any slower than 0.3s – but this seemed like such an obvious thing to want to do, and yet the WRONG way of doing it, I wondered if anyone could point me to a plugin/filter/hook that would get this done neater.
minor savedqueries query:
I added define(‘SAVEQUERIES’, true); to wordpres/index.php before require(‘./wp-blog-header.php’) and it just doesn’t seem to have any effect. This must be PHP weirdness because a multi-file search shows it is only used in wp-dp.php which only defines it false if undefined.
hacking the top bit of wp-db.php so it defines it as true means that the if (SAVEQUERIES) lines later on do happen and gives me the info i was after (above)
- The topic ‘using cache on the homepage 10 records (and a minor SAVEDQUERIES query)’ is closed to new replies.