--- fb.module	2011-09-15 22:51:43.000000000 -0700
+++ patch	2011-09-16 13:46:29.000000000 -0700
@@ -1440,20 +1440,25 @@
   // This function can be called very early in the bootstrap process, before
   // the modules are initialized, in which case we will fail to alter the
   // name.
-  if (isset($GLOBALS['_fb']) && $fbu = fb_get_fbu($account)) { // @TODO - is fb_get_fbu() a performance hit here?
-    try {
-      // Use fql query instead of graph api, because it will succeed more often.
-      $data = fb_fql_query($GLOBALS['_fb'], "SELECT name FROM user WHERE uid=$fbu", array(
-                             'access_token' => fb_get_token($GLOBALS['_fb']),
-                           ));
-      if (count($data) && isset($data[0]['name'])) {
-        $name = $data[0]['name'];
+  if (variable_get('fb_connect_theme_username_1', FALSE)) {
+    if ($GLOBALS['_fb'] && $fbu = fb_get_fbu($account)) { // @TODO - is fb_get_fbu() a performance hit here?
+      try {
+        $name = cache_get('fb_username_' . $fbu);
+        if (!$name) {
+          // Use fql query instead of graph api, because it will succeed more often.
+          $data = fb_fql_query($GLOBALS['_fb'], "SELECT name FROM user WHERE uid=$fbu", array(
+              'access_token' => fb_get_token($GLOBALS['_fb']),
+                  ));
+          if (count($data) && isset($data[0]['name'])) {
+            $name = $data[0]['name'];
+            cache_set('fb_username_' . $fbu, $name, 'cache', CACHE_TEMPORARY);
+          }
+        }
+      } catch (Exception $e) {
+        fb_log_exception($e, t('Failed to alter username for facebook user %fbu', array(
+                    '%fbu' => $fbu)));
       }
     }
-    catch (Exception $e) {
-      fb_log_exception($e, t('Failed to alter username for facebook user %fbu', array(
-                               '%fbu' => $fbu)));
-    }
   }
 }
 
