diff --git a/includes/form.inc b/includes/form.inc
index 130775f..f1e513b 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -555,8 +555,16 @@ function form_get_cache($form_build_id, &$form_state) {
  * Stores a form in the cache.
  */
 function form_set_cache($form_build_id, $form, $form_state) {
-  // 6 hours cache life time for forms should be plenty.
-  $expire = 21600;
+  // The default form cache lifetime is 6 hours. On busy sites, the cache_form
+  // table can become very large. A shorter form_cache lifetime means entries
+  // will expire more rapidly, which should help to keep the table's size under
+  // control.
+  if (isset($form['#cache_expiry'])) {
+    $expire = $form['#cache_expiry'];
+  }
+  else {
+    $expire = variable_get('form_cache_expiry', 21600);
+  }
 
   // Ensure that the form build_id embedded in the form structure is the same as
   // the one passed in as a parameter. This is an additional safety measure to
