I'm working on Drupal11 site and I'd like use Statistics module.
The site will be available behind Varnish, a reverse proxy that bypass normal Drupal bootstrap, if the url is in cache.

Does this module work also in this situation?
On Drupal 7 I remember an option to enable Ajax behaviour.

Thanks,
Sergio

Comments

arrubiu created an issue. See original summary.

arrubiu’s picture

Title: Ajax for reverse cache? » Ajax for Varnish cache?
fgm’s picture

The way Statistics works is that statistics.js is loaded with the page, then sends a POST XHR to <siteroot>/modules/contrib/statistics/statistics.php which returns an uncacheable response. It no longer needs a specific configuration for AJAX, just make sure counting is enabled : for compatibility with older core versions, it is disabled by default. This means:

  • This is supported by default with any reverse proxy (RP), since the call is performed in JS
  • The RP config MUST NOT strip JS (I don't think I ever saw that, but...)
  • The RP config MUST NOT ignore cacheability headers. Varnish does things correctly by default, but a custom complex config might overlook that specific case
  • The RP AND Web server config must allow access to the <siteroot>/modules/contrib/statistics/statistics.php path. Many configurations block all PHP pages except the front controller and need a specific exception