page_cache

WordPress uses page_cache global variable to cache static pages by their ID. Caching can notably improve performance by retrieving data from memory and avoiding repeated queries to the database. It is an array set in the function update_page_cache(&$pages) defined in [wordpress root folder]/wp-includes/functions.php.

WordPress uses page_cache internally in the functions to retrieve pages:

  • get_pages($args = ''): retrieves the static pages according to the arguments provided. Following arguments are supported:
    • child_of: if specified, the function retrieves the children of specified page ID.
    • sort_column: attribute of the page that should be used for sorting, which is implemented as column name in the wp_posts table in the database.
    • sort_order: order for sorting, currently supports ASC and DESC.
    • exclude: includes IDs of pages that should be excluded from the retrieval.
  • get_page_children($page_id, $pages): retrieves child pages of the specified page. If $pages argument is empty, $page_cache global variable is used.

Plugin and theme developers can use page_cache to write custom functions which involve retrieving page data.

Back to full list of global variables.

Technorati tags: ,

One Response to “page_cache”


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: