From 921c060e18cbab3c95490c3d0ddafe98bb3ffd25 Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Wed, 31 Oct 2012 21:39:23 +0000 Subject: [PATCH] When receiving a HEAD request, die() right before we start outputting content. * Content doesn't make sense for HEAD requests * Saves wear and tear on the server * Introduces a filter: exit_on_http_head (we send TRUE through it) fixes #14348. props mbijon, mitchoyoshitaka. git-svn-id: https://develop.svn.wordpress.org/trunk@22347 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/template-loader.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wp-includes/template-loader.php b/wp-includes/template-loader.php index fdf75f15ec..b7b12cd502 100644 --- a/wp-includes/template-loader.php +++ b/wp-includes/template-loader.php @@ -6,6 +6,14 @@ if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) do_action('template_redirect'); +/** + * Halt template load for HEAD requests. Performance bump by eliminating output + * + * @since 3.5.0 + */ +if ( 'HEAD' === $_SERVER['REQUEST_METHOD'] && apply_filters( 'exit_on_http_head', true ) ) + exit(); + // Process feeds and trackbacks even if not using themes. if ( is_robots() ) : do_action('do_robots');