diff --git a/ajax/authcache.php b/ajax/authcache.php
index 428921a..e3d4d7f 100644
--- a/ajax/authcache.php
+++ b/ajax/authcache.php
@@ -118,6 +118,25 @@ function _authcache_form_token_id($vars) {
/**
+ * Return debug information for the given page request.
+ */
+function _authcache_debuginfo($key) {
+ include_once dirname(__FILE__) . '../authcache.helpers.module';
+ $info = array();
+
+ if (_authcache_debug_access()) {
+ $cache = cache_get($key, 'cache_page');
+
+ if ($cache) {
+ $info = $cache->data['authcache_info'];
+ }
+ }
+
+ return $info;
+}
+
+
+/**
* Node history
* @see node.module
*/
diff --git a/authcache.admin.inc b/authcache.admin.inc
index d15555b..9762266 100644
--- a/authcache.admin.inc
+++ b/authcache.admin.inc
@@ -318,7 +318,7 @@ function authcache_admin_pagecaching($form, $form_state, $ajax_form = array()) {
'#collapsible' => TRUE,
'#collapsed' => (variable_get('authcache_nonhtml', AUTHCACHE_NONHTML_DEFAULT) == AUTHCACHE_NONHTML_DEFAULT),
'#title' => t('Non-HTML Cached Pages'),
- '#description' => t('JavaScript is appended at the end of pages to support Ajax callbacks and page manipulation ("var authcacheFooter"). If you are experiencing issues for some content, you may disable this by entering pages below that you wish to cache but do not want JavaScript appended to.'),
+ '#description' => t('You may enable caching of non-HTML content other than text/javascript, text/plain, application/xml, application/atom+xml by entering paths to those pages here.'),
'#prefix' => '
',
);
$form['nonhtmlfs']['nonhtml'] = array(
diff --git a/authcache.debug.js b/authcache.debug.js
index 555a2a0..07a51cf 100644
--- a/authcache.debug.js
+++ b/authcache.debug.js
@@ -7,70 +7,18 @@
* Display debug info, depending on phase
*/
Authcache.debug = function(ajaxData) {
+ var debugInfo;
if (!ajaxData) {
+ jQuery("body").prepend("");
+ jQuery("#authcachehide").click(function() {jQuery("#authcachedebug").toggle(); return false; })
- legend = (jQuery.cookie('drupal_user')) ? " (logged in: "+jQuery.cookie('drupal_user')+')' : '';
-
- //if (Authcache.isEnabled) {
- //simg: changed to authcache.info to help make more debug info available more often
- if (Authcache.info) {
- // Get seconds page was last cached, using Unix Epoch (GMT/UTC timestamp)
- utc = (new Date()).toUTCString(); // Client's time
- utcTimestamp = Date.parse(utc) / 1000; // Convert to seconds
-
- Authcache.info["(page_age)"] = Math.round(utcTimestamp - Authcache.info.cache_time) + " seconds";
- jQuery("#authcache-info").html("This page was cached " + Authcache.info["(page_age)"] + " ago.");
- if (utcTimestamp - Authcache.info.cache_time < -10) {
- jQuery("#authcache-info").append("Your computer's
time may be off.
");
- }
-
- var cache_render_time = jQuery.cookie("cache_render");
- jQuery.cookie("cache_render",null);
- var alert_color = '#F7F7F7';
- if (!jQuery.cookie('authcache_debug')) {
- Authcache.info.cache_render = 'This is your first site visit and the debug cookie has just been set.';
- }
- else if(cache_render_time && !isNaN(cache_render_time)) { // numeric?
- Authcache.info.cache_render = cache_render_time + " ms"
- Authcache.info.cache_render += " (" + Math.round((Authcache.info.page_render - cache_render_time) / cache_render_time * 100).toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2') + "% increase)"
- if (cache_render_time < 30) alert_color = 'green';
- else if (cache_render_time < 100) alert_color = 'orange';
- else if (cache_render_time > 100) alert_color = 'red';
- }
- else if(!cache_render_time) {
- Authcache.info.cache_render = 'cache miss';
- var alert_color = 'red';
- }
- else {
- Authcache.info.cache_render = "n/a (try a different browser?)";
- var alert_color = 'red';
- }
- //if (jQuery.cookie('authcache_compression')) {
- //Authcache.info.compression = jQuery.cookie('authcache_compression');
- //}
-
- //Authcache.info.page_render += " ms"; //simg: why was this here?
-
- debugInfo = Authcache.debugFieldset("Authcache.info"+legend, Authcache.info);
-
- if (Authcache.isEnabled) {
- debugInfo += 'Disable caching for this browser session';
- } else {
- if (jQuery.cookie("nocache")) {
- debugInfo += 'Enable caching for this browser session';
- }
- }
- }
- else {
- if (JSON.stringify(Authcache.info) == "{}") Authcache.info = "Authcache.info JSON is empty. @see _authcache_shutdown_save_page()";
- //Authcache.info = "Authcache.info JSON is empty. @see _authcache_shutdown_save_page()";
- debugInfo = Authcache.debugFieldset("Authcache prevented caching", {"NO_CACHE" : "Page not cached.", "INFO" : Authcache.info });
+ Authcache.debugCacheRenderTime = jQuery.cookie("cache_render");
+ jQuery.cookie("cache_render",null);
+
+ if (Drupal.settings.Authcache.info) {
+ Authcache.debugUpdate(Drupal.settings.Authcache.info);
}
-
-
- jQuery("body").prepend("");
- jQuery("#authcachehide").click(function() {jQuery("#authcachedebug").toggle(); return false; })
Authcache.debugTimer();
}
@@ -84,11 +32,75 @@ Authcache.debug = function(ajaxData) {
Authcache.debugFieldset("Response:", ajaxData.received) +
"";
+ if (typeof ajaxData.received.debuginfo != "undefined") {
+ Authcache.debugUpdate(ajaxData.received.debuginfo);
+ }
+
jQuery("#authcachedebug").append(debugInfo);
Authcache.debugTimer();
}
}
+Authcache.debugUpdate = function(info) {
+ var debugInfo;
+
+ // Get seconds page was last cached, using Unix Epoch (GMT/UTC timestamp)
+ utc = (new Date()).toUTCString(); // Client's time
+ utcTimestamp = Date.parse(utc) / 1000; // Convert to seconds
+
+ if (info.cache_time) {
+ info["(page_age)"] = Math.round(utcTimestamp - info.cache_time) + " seconds";
+ jQuery("#authcache-info").html("This page was cached " + info["(page_age)"] + " ago.");
+ if (utcTimestamp - info.cache_time < -10) {
+ jQuery("#authcache-info").append("Your computer's
time may be off.
");
+ }
+ }
+
+ var alert_color = '#F7F7F7';
+ if (!jQuery.cookie('authcache_debug')) {
+ info.cache_render = 'This is your first site visit and the debug cookie has just been set.';
+ }
+ else if(Authcache.debugCacheRenderTime && !isNaN(Authcache.debugCacheRenderTime)) { // numeric?
+ info.cache_render = Authcache.debugCacheRenderTime + " ms"
+ info.cache_render += " (" + Math.round((info.page_render - Authcache.debugCacheRenderTime) / Authcache.debugCacheRenderTime * 100).toString().replace(/(\d+)(\d{3})/, '$1' + ',' + '$2') + "% increase)"
+ if (Authcache.debugCacheRenderTime < 30) alert_color = 'green';
+ else if (Authcache.debugCacheRenderTime < 100) alert_color = 'orange';
+ else if (Authcache.debugCacheRenderTime > 100) alert_color = 'red';
+ }
+ else if(!Authcache.debugCacheRenderTime) {
+ if (jQuery.cookie('nocache_reason')) {
+ info.cache_render = jQuery.cookie('nocache_reason').replace(/\+/g, " ");
+ }
+ else {
+ info.cache_render = "Cache miss";
+ }
+ var alert_color = 'red';
+ }
+ else {
+ info.cache_render = "n/a (try a different browser?)";
+ var alert_color = 'red';
+ }
+ //if (jQuery.cookie('authcache_compression')) {
+ //info.compression = jQuery.cookie('authcache_compression');
+ //}
+
+ //info.page_render += " ms"; //simg: why was this here?
+
+ legend = (jQuery.cookie('drupal_user')) ? " (logged in: "+jQuery.cookie('drupal_user')+')' : '';
+ debugInfo = Authcache.debugFieldset("info"+legend, info);
+
+ if (Authcache.isEnabled) {
+ debugInfo += 'Disable caching for this browser session';
+ } else {
+ if (jQuery.cookie("nocache")) {
+ debugInfo += 'Enable caching for this browser session';
+ }
+ }
+
+ jQuery("#authcache_status_indicator").css({"background": alert_color});
+ jQuery("#authcachedebuginfo").first().html(debugInfo);
+}
+
/**
* Disable caching by setting cookie
*/
diff --git a/authcache.helpers.inc b/authcache.helpers.inc
index 4fa90fe..2a0d9cb 100644
--- a/authcache.helpers.inc
+++ b/authcache.helpers.inc
@@ -248,17 +248,14 @@ function _authcache_shutdown_save_page() {
'page_render' => timer_read('page'), // Benchmark
'page_queries' => '-1', // Database benchmark, if enabled
'cache_render' => '-1', // Filled by cookie via JS on cache request
- 'cache_uid' => $user->uid, // Required by JS for HTML updates
'cache_class' => variable_get('cache_class_cache_page', 'unknown'),
- 'cache_time' => REQUEST_TIME, // Required by JS for HTML updates,
'is_cacheable' => $_authcache_is_cacheable,
'cache_key' => $key,
+ 'debug_users' => variable_get('authcache_debug_users', array()),
));
- // Hide sensitive info from anonymous users
- if (variable_get('authcache_debug_all', FALSE) || !_authcache_debug_access()) {
- unset($_authcache_info['cache_uid']);
- unset($_authcache_info['cache_inc']);
+ if (!$_authcache_is_cacheable && _authcache_debug_access()) {
+ setcookie('nocache_reason', $_authcache_info['no_cache_reason'], 0, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure') == '1');
}
// Database benchmarks
@@ -278,50 +275,10 @@ function _authcache_shutdown_save_page() {
unset($_authcache_info['page_queries']);
}
- // JSON to send via Ajax
- // The "q" key is need during Ajax phase
- $authcache_ajax = array(
- 'q' => $_GET['q'],
- );
-
- // Invoke hook_authcache_info() operation to allow modules to modify info array
- _authcache_invoke_hook('authcache_info', $_authcache_info);
-
- // Invoke hook_authcache() operation to allow modules to modify ajax array
- _authcache_invoke_hook('authcache_ajax', $authcache_ajax);
-
// Get buffered HTML
$buffer = ob_get_contents();
// ob_end_clean();
- if (substr($buffer, 0, 5) == 'uid && ($debug_users = variable_get('authcache_debug_users', array()))))
- && !$is_cached_nonhtml
- ) {
- $js = '';
-
-
-
- // Insert JSON before