0

Using Google Analytics Reports module latest version 7.x-3.0-beta2. I wanted to make this module to make requests in non-blocking fashion. Standard drupal makes it blocking fashion, which slows things down.

I started looking into Background Process module, which looks promising. Other option is HTTPRL module, which is similar to Background Process.

Right now I am using AJAX for fetching GA API reporting data, but I feel it's slow, because of how drupal_http_request works (synchronous, blocking way).

Is it possible to integrate non-blocking requests to fetch data from GA API without rewriting excellent Google Analytics Reports module?

4
  • Just to clarify, you're wanting to make asynchronous HTTP call in the context of an AJAX request? How is the client going to receive data back once the asynchronous HTTP call is finished?
    – Shawn Conn
    Commented Aug 27, 2015 at 19:38
  • @ShawnConn, basically I mean that GA API calls can be made asynchronously (to speed getting data from external server), and then when all requests are finished - AJAX will spit out the result of it to user. Maby I'm asking too much and misunderstand the concept of asynchronous? Commented Aug 28, 2015 at 8:27
  • I'm trying to clarify exactly what you're asking. If it's what I think it is, you're wanting to make 2 async calls: AJAX to Drupal then Drupal to the GA API.
    – Shawn Conn
    Commented Aug 28, 2015 at 16:58
  • Yes, that's what I want. Is this possible? Commented Sep 4, 2015 at 16:41

1 Answer 1

1

This is not possible in the manner that you described. Sure you can make a chain of asynchronous calls, the browser AJAX request to Drupal then Drupal making a non-blocking HTTP request to the GA API. However, your AJAX call won't have data to use.

The Background Process & HTTPRL (check out the project page image) work by the request being one way; they are calling out to a URL that will trigger some background action that doesn't need to communicate back (e.g. some batch job or page crawler cron task). In your case, you need the GA API to communicate back with Drupal then Drupal to communicate back with the browser. There's no getting around that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.