I have a long job serving to fill a table in a db. This job may takes various time to finish. So, I need a progress bar. Just counting on the page is enough. As far I found several solutions:
- Using _SESSION. OK, it works on most of servers I used, but I have many problem with ERR_RESPONSE_HEADERS_TOO_BIG error on chrome and sometimes - "headers already sent" on some servers, caused by session_start/session_write_close called in a loop. I loved this method but now I have reject it
- Using kind of ob_start/ob_end_flush inside of the long operation's loop. This doesn't work. It just displays all buffered echo-ed messaged after the end of script.
- Using db to store a shared variable (not tried yet)
- Using separate (temporary) file. (not tried yet).
I have already implemented infrastructure: one script for long job (populating a table in db) and another one used by JS to read shared variable containing progress status. Both these scripts I called with jQuery .ajax method expecting the results in .done function.
Is there any other methods? It seems I will like to use 4) variant, but I want to know what is the usual practice for implementing progress bar.
Thanks:)