drupal_add_js settings and working around the anonymous page cache What I'm trying to do is allow registered users to configure a few colors on public facing pages (profiles, etc.) and to do so I'm using the ColorField module and a few theme functions.

My problem is that the anonymous page cache is caching values stored in Drupal.settings, preventing changes from being visible until the page cache is cleared.

Here is the code I currently use to set Drupal.settings:

&lt;?php
function themeName_preprocess_page(&amp;$vars) {
  $branding = array(
      'header_bg' =&gt; '#ffffff',
      'accent' =&gt; '#0b40ac'
  );
  drupal_add_js(array('pageRebranding' =&gt; $branding), array('type' =&gt; 'setting'));
  drupal_add_js(drupal_get_path('theme', 'themeName') .'/js/branding.js');
}
?&gt;


Disabling the anonymous page cache (globally or selectively) is not an option.

Is there a way I can pass values to Drupal.behaviors using ajax on page load, or another method to get around the anonymous page cache?

Here is my JS: 

(function ($) {

    Drupal.behaviors.pageRebranding = {
        attach: function (context, settings) {
            var header_bg = Drupal.settings.pageRebranding.header_bg;
            var accent = Drupal.settings.pageRebranding.accent;
            /* Do Stuff */
        }
    };

})(jQuery);
You can avoid the cache by calling your file using

drupal_add_js(drupal_get_path('theme', 'themeName') .'/js/branding.js', array('cache' =&gt; FALSE));