I have a block that makes a request to an external webservice to get some results, and renders them back on the page. It is loading slowly, adding 4-5 seconds to the page load time, so I decided to use Ajax Blocks to load it in.

When setting this block to load with Ajax, it did not reduce the page load time. The page still took 4-5 seconds to load, and the block would then load with ajax. I turned on xhprof and found that the PHP eval function from php.module was still running on the request, so it was not being excluded and loaded with ajax. It seemed to be loading on the page request and then called again by ajax (I tested this by added a 5s load delay to the block).

My expectation was that it would not be part of the initial page request, but would be run as a separate request via Ajax Blocks module and then the content would be replaced in the page. Is the loading of PHP blocks supported, and if not, can you recommend a way to do this? Thanks in advance.

Comments

crazyrohila’s picture

Same thing happened for me. XHProf is showing block_view function call in initial page call even if block is rendered by ajax.
Any updates on this one?

maximpodorov’s picture

Currently, the block does execute then the page is rendered. It's not easy to change this behavior since the block can add JS and CSS code to the page.

M Faheem’s picture

Same is happening to me, I am trying to use $_SERVER["HTTP_CF_IPCOUNTRY". When loaded though ajax block it's giving two seperate values, one cached and one from the server.

HansKuiters’s picture

There is a patch. #2049195: Block is rendered even though it is loaded via AJAX. I'm marking this as duplicate.

HansKuiters’s picture

Status: Active » Closed (duplicate)