A
A
alestro2016-12-11 21:59:36
Laravel
alestro, 2016-12-11 21:59:36

Does TERMINABLE MIDDLEWARE make any practical sense?

Is there any benefit from using this feature? As far as I understand, this thing helps speed up page loading, they say the response is displayed in the browser, and the resource-intensive operation is performed after, but in fact I got the following: I return from the 'hello world' route, I add the following to the terminate method of a specially created middlewar:

$m = 9999999;
    while($m--){
      $arr[] = $m**10;
    }

And logically, the answer from the route should come immediately, but in fact it turns out that the answer is displayed only after the cycle has been completed. So, what then is the profit from this bun?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vyacheslav Plisko, 2016-12-12
@AmdY

It is better to check through sleep. As far as I understand, headers and flash data are sent there, but perhaps your server uses buffering.
The feature is rather dubious, it doesn’t belong in the middleware, it’s better to use the queue.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question