Adding rewrite rules and $wp_rewrite->flush_rules()
-
Hi,
I’ve been struggling with this for a while, and the documentation on the rewrite API is a little scarce. So I hope someone’s out there who can shed some light on this.
If I add rewrite rules, do I have to flush the rules on every page load? It seems that if I don’t flush them, it will keep working for a short while. Then after a couple of minutes it will break.
Flushing the rules currently causes an extra 100 (!) mysql queries on each page load. The queries look like this:
[23] => Array ( [0] => SELECT * FROM wp_posts WHERE ID = 5106 LIMIT 1 [1] => 0.000135898590088 [2] => require, wp, WP->main, do_action_ref_array, call_user_func_array, XIC_flush, WP_Rewrite->flush_rules, WP_Rewrite->wp_rewrite_rules, WP_Rewrite->rewrite_rules, WP_Rewrite->page_rewrite_rules, WP_Rewrite->page_uri_index, get_page_uri, get_page, get_post ) [24] => Array ( [0] => SELECT <code>post_parent</code> FROM wp_posts WHERE ID = 5068 LIMIT 1 [1] => 0.0001220703125 [2] => require, wp, WP->main, do_action_ref_array, call_user_func_array, XIC_flush, WP_Rewrite->flush_rules, WP_Rewrite->wp_rewrite_rules, WP_Rewrite->rewrite_rules, WP_Rewrite->page_rewrite_rules, WP_Rewrite->page_uri_index, get_page_uri, get_page, get_post, _get_post_ancestors ) [25] => Array ( [0] => SELECT ID, post_name, post_parent FROM wp_posts WHERE post_type = 'attachment' AND post_parent = 5106 [1] => 0.000179052352905 [2] => require, wp, WP->main, do_action_ref_array, call_user_func_array, XIC_flush, WP_Rewrite->flush_rules, WP_Rewrite->wp_rewrite_rules, WP_Rewrite->rewrite_rules, WP_Rewrite->page_rewrite_rules, WP_Rewrite->page_uri_index )
They are “small” queries, but still I’d love to get rid of them..
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Adding rewrite rules and $wp_rewrite->flush_rules()’ is closed to new replies.