diff --git a/includes/common.inc b/includes/common.inc
index 57c7197..a7fb517 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -702,6 +702,14 @@ function drupal_goto($path = '', array $options = array(), $http_response_code =
 
   header('Location: ' . $url, TRUE, $http_response_code);
 
+  // Allow caching of 301 responses.
+  if ($http_response_code == 301 && variable_get('cache', 0) && ($cache = drupal_page_set_cache())) {
+    // We must output something to allow the request to be cached.
+    echo ' ';
+
+    drupal_page_footer();
+  }
+
   // The "Location" header sends a redirect status code to the HTTP daemon. In
   // some cases this can be wrong, so we make sure none of the code below the
   // drupal_goto() call gets executed upon redirection.
