Hi there,

First of all, thanks for a great module!

I'm using this on some radio station web sites to refresh 'on air now' info blocks. It works a treat.

However under some circumstances anonymous users are seeing stale 'on air now' info. As far as I can tell, drupal is serving cached pages with stale data prior to the first triggered block refresh.

To defeat this it would be awesome to add an option to refresh on initial page load as well as after xxx seconds. There would be a small performance hit, but it's much preferable to flushing the whole page cache and re-rendering.

I had a quick look at the code this morning, and I figure this shouldn't be too hard to do. I'll submit a patch shortly.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tripper54’s picture

Assigned: tripper54 » Unassigned
Status: Active » Needs review
FileSize
5.63 KB

Here's a bash at it.

0mni’s picture

Works well, but you have a big bug in your patch :)

The top of block_refresh.js needs to be as follows:

(function ($) {
Drupal.behaviors.block_refresh = {
  attach: function(context) {
		$.each(Drupal.settings.block_refresh.settings, function(key, settings) {
			var element = settings.element;
      setBlockRefresh('#' + element, '.content', settings['auto'], settings['manual'], settings['init'], settings['timer'], settings['block']['block'], settings['block']['delta']);
      
      if (settings['panels']) {
        element = element.replace('block-', 'pane-');
        setBlockRefresh('.' + element, '.pane-content', settings['auto'], settings['manual'], settings['init'], settings['timer'], settings['block']['block'], settings['block']['delta']);
      }
		});
tripper54’s picture

Well spotted.

Updated patch attached.

tripper54’s picture

Issue summary: View changes
Status: Needs review » Fixed

(updated version) committed to 7.x-2.x branch

  • Commit dcd26fd on 7.x-2.x by tripper54:
    Issue #2072245 by tripper54: add checkbox to refresh on page load
    

  • Commit dcd26fd on 7.x-2.x, 8.x-1.x by tripper54:
    Issue #2072245 by tripper54: add checkbox to refresh on page load
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.