Just realized that this module has support for the advagg=0 option to disable caching on a page. This is an excellent idea and something I've wanted a lot as I typically do development on live sites to quickly fix issues related to css / js. I wrote a module called entity_Iframe that has a similar concept of a query param that can modify behavior in a module called "entity_iframe_mode".

http://drupalcode.org/project/entity_iframe.git/blob/refs/heads/7.x-1.x:...

I think that this approach could be modified for those with the permission to use the advagg=0 option so that once it's added to a url that all pages they go to maintain the debugging mode. This way as you navigate the site you as an admin wouldn't have to continue to add that option to the url, it would just auto append to links as you navigate around. The code to do so is rather simple and could be something like:

/**
   * Implements hook_url_outbound_alter().
   *
   * Allow for maintaining of a quazi "advagg bypass mode".
   */
function advagg_url_outbound_alter(&$path, &$options, $original) {
  // test if we are in by-pass mode and have access to utilize it
  if (_advagg_mode_enabled() && user_access('bypass advanced aggregation')) {
    $options['query']['advagg'] = 0;
  }
}

/**
  * Test that we are in advagg bypass mode
  */
function _advagg_mode_enabled() {
  if (isset($_GET['advagg']) && !$_GET['advagg']) {
    return TRUE;
  }
  return FALSE;
}

In entity iframe I have this as a separate module and probably would recommend doing so here if it's functionality people are interested in as it might not be expected behavior for those using this for awhile. I expected it to maintain the mode but that's just cause I wrote the other module.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikeytown2’s picture

If you go to admin/config/development/performance/advagg/operations you can click a button (Toggle the "aggregation bypass cookie" for this browser) which will drop a cookie that will then allow one bypass advagg just for that user.

If this does not satisfy your needs please explain why. If this does work for you go ahead and mark this issue as "closed (works as designed)" :)

JS code for the cookie:
http://drupalcode.org/project/advagg.git/blob/refs/heads/7.x-2.x:/advagg...
PHP code if JS is disabled:
http://drupalcode.org/project/advagg.git/blob/1c4c0b7b38d188f0025e019dcb...

btopro’s picture

Thanks for pointing that out, never noticed it before. This does seem like it produces a similar result but I'm wondering if this would be more difficult to debug in certain instances. Example: I almost always get css compression issues w/ certain properties when using a remote compressor to minify things. People are noticing issues and I've pushed that button before so I'm not seeing them on my end. I rarely close my browser / session and debugging this becomes rather exotic as I've forgotten about this button. A glance at the url token and I'm aware immediately that something is up if I know about this module.

Georgii’s picture

Hi, mikeytown2, I'd suggest adding a fallback from JS to PHP code for Unicode domains like ".рф". Unfortunately for such domains the cookie is not being set.

My proposal:

function isUnicode(str){
  for (var i = 0, n = str.length; i < n; i++) {
    if (str.charCodeAt( i ) > 255) {
      return true;
    }
  }
  return false;
}

function advagg_toggle_cookie() {
  // Fallback to submitting the form for Unicode domains like ".рф"
  if (isUnicode(document.location.hostname)) {
    return true;
  }


  var cookie_name = 'AdvAggDisabled';
  // See if the cookie exists.
  var cookie_pos = document.cookie.indexOf(cookie_name + '=' + Drupal.settings.advagg.key);
  // If the cookie does exist then remove it.
  if (cookie_pos !== -1) {
    document.cookie = cookie_name + '=;'
    + 'expires=-1;'
    + ' path=' + Drupal.settings.basePath + ';'
    + ' domain=.' + document.location.hostname + ';';
    alert(Drupal.t('AdvAgg Bypass Cookie Removed'));
  }
  // If the cookie does not exist then set it.
  else {
    document.cookie = cookie_name + '=' + Drupal.settings.advagg.key + ';'
    + ' path=' + Drupal.settings.basePath + ';'
    + ' domain=.' + document.location.hostname + ';';
    alert(Drupal.t('AdvAgg Bypass Cookie Set'));
  }
  // Must return false, if returning true then form gets submitted.
  return false;
} 
mikeytown2’s picture

@Georgii
What if I were to encodeURIComponent the hostname?
+ ' domain=.' + encodeURIComponent(document.location.hostname) + ';';

@btopro
So I need to have some sort of indicator that the bypass cookie is set? I could do a drupal_set_message when I detect the cookie
http://drupalcode.org/project/advagg.git/blob/696710686bbcd4e99f299f07e8...

Georgii’s picture

mikeytown2,
Unfortunately it does not work.

E.g. for 'домен.рф' (like domain.com) the document.cookie expects xn--d1acufc.xn--p1ai. However encodeURI gives %D0%B4%D0%BE%D0%BC%D0%B5%D0%BD.%D1%80%D1%84.

A quick search on this topic showed something like this
http://stackoverflow.com/questions/183485/can-anyone-recommend-a-good-fr...
https://github.com/bestiejs/punycode.js/

But I don't think this is something to be implemented for this module. The case is too specific. I'd stick to the fallback approach, what do you think?

mikeytown2’s picture

Fallback sounds good. The following patch has been committed.

mikeytown2’s picture

Status: Active » Needs review
FileSize
2.04 KB

@btopro
Can you checkout this patch?

Georgii’s picture

Status: Needs review » Active

mikeytown2,
Thanks!

mikeytown2’s picture

Was talking with a co-worker about this and the suggestion was to make the cookie only last 12 hours. Thoughts?

Georgii’s picture

mikeytown2, what is the point? Some kind of security?

mikeytown2’s picture

Nothing to do with security. Having the cookie persist after the browser is closed for 12 hours is the reason.

Georgii’s picture

I think that having a persistent cookie is a good idea.

mikeytown2’s picture

Status: Active » Fixed
FileSize
3.61 KB

Following patch has been committed.

mikeytown2’s picture

Following patch has been committed.

Georgii’s picture

Title: Make ?advagg=0 option pervasive for admins » Make ?advagg=0 option pervasive for admins (+ a cookie to bypass aggregation)
Status: Fixed » Closed (fixed)
  1. Successfully verified using advagg 7.x-2.0-rc1.
  2. Updated issue title
  3. Submitted a feature request as a follow up - #2056955: Add AdvAgg cache flush on module install