Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Performing a full bootstrap + rendering a view is very expensive and can negatively affect the performance of the site, if done at each refresh.
Instead, it is suggested to let the module accept an additional, arbitrary URL that can be hit at each refresh interval to determine whether there's something to refresh or not. Because this is a hand-made script, it will be much more efficient than a full-scale view rendering.
Comments
Comment #1
infojunkieImplemented in latest dev. Here's how it works:
The additional theme parameter
ping_base_path
is used to inform Views Auto-Refresh that this URL should be hit before the secondary view. The script at this ping URL should accept a GET parameter calledtimestamp
and return a JSON response of the following form:where
$count
is 0 if there are no new items sincetimestamp
, > 0 otherwise.For example, here's a complete ping script:
This script illustrates parsing the Drupal MySQL connection string, getting a number of parameters including
timestamp
, and returning the expected JSON response.Comment #2
infojunkieThe Views Auto-Refresh theme function should be called with an additional setting
ping_base_path
as such:Comment #3
l00ph0le CreditAttribution: l00ph0le commentedAny idea if this will work in D7? Looks great btw, exactly what I am looking for.
Comment #4
infojunkieI'm currently focusing on D6, no plans to move to D7 unless someone else wants to undertake the port.
Comment #5.0
(not verified) CreditAttribution: commentedReworded.