diff --git a/cas.module b/cas.module
index 171edb2..8d8cc79 100644
--- a/cas.module
+++ b/cas.module
@@ -16,6 +16,34 @@ define('CAS_LOGIN_REDIR_MESSAGE', 'You will be redirected to the secure CAS logi
 define('CAS_EXCLUDE', 'services/*');
 
 /**
+ * Implementation of hook_boot().
+ * 
+ * Allow use of CAS gateway mode when caching is enabled
+ */
+function cas_boot() {
+  global $conf;
+  
+  // we only want to run this code if hook_boot is called from _drupal_bootstrap_page_cache()
+  // and not _drupal_bootstrap_page_header()
+  if (!isset($_COOKIE[session_name()])) {
+    
+    // pre-requesites for subsequent drupal_get_path() calls
+    require_once './includes/path.inc';
+    drupal_language_initialize();
+
+    $force_authentication = _cas_force_login();
+    $check_authentication = _cas_allow_check_for_login();
+
+    if ($force_authentication || $check_authentication) {
+      // disable caching for this page request
+      $conf['cache'] = FALSE;
+      // then we resume the bootstrap phase
+      drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
+    }
+  }
+}
+
+/**
  * Implements hook_init().
  *
  * Traps a page load to see if authentication is required.
