Activity block counters

Adding page views to your Drupal site is quite easy with the Statistics module. The only issue with this approach is that the module runs on every page and often gathers unnecessary details. While this module is innocuous on smaller sites, larger sites will see performance issues.

CyAC wanted a lightweight page view counter that displayed only on specified pages. The block had to have accurate counters for the current day, the previous day, and a lifetime total. Using a cron job that is run at midnight, Monarch moves the Today counter to Yesterday and resets the Today counter to zero. 

The block also needed to be updated dynamically after each page load. This, of course, was a big problem when used in combination with caching. Monarch used 0n AJAX call on each page load (that contain the block) and updates the number of views dynamically. Using this approach, anonymous users will see the block numbers update immediately even if strict caching is implemented.