I would schedule the creation of the file, generate it, and then send a notification to the user when it's ready. However, 60 seconds to generate a file is way too long, I would analyze the queries to see what takes such a long time, and then add the proper indexes, because it's very likely the database queries that have bad performance.
Can not download multiple excel sheets in one request.
I am using this package: laravel-excel
the code to generate the excel file: return Excel::download(new Students_Data_Chart_Export($students, $heading),'Students Data .xlsx');
where $students is the data for excel sheet and $heading is the heading of excel sheet.
While downloading, if the excel contains 1800 students data to calculate, the time to process exceeds 1 minute, in which case the Cloudflare gives error: A time out occurred, because server is calculating for 1 minute and is not responding.
I am thinking to split that 1800 students based on class, because there are 300 students in 1 class. So, if I can download 6 excels per request, there will be 1 excel downloaded in 15 sec. for 1800, it will take 1 minute + so the error is occurring, so this class wise excel method will download 6 excel files. Overall time will take 1 minute+, but while the server is responding in 15 sec, Cloudflare won't give an error.
Problem is, I can not download multiple excel sheets in 1 request. I can not write:
Excel::download(new Students_Data_Chart_Export($students2, $heading),'Students Data Grade 1 .xlsx');
return Excel::download(new Students_Data_Chart_Export($students2, $heading),'Students Data Grade 2 .xlsx');
etc...
where $students1 is students from grade 1 and $students2 is students from grade 2. the only statement that excutes is statement 2 i.e. statement with return keyword.
I need help with this problem.
@omsutariya sounds like you don't actually want to consider alternative solutions.
What you want to do breaks http protocol. The browser issues a request, for which it expects a single response. You cant change the way browsers work.
You would need to get the client to request students per grade as separate requests.
Please or to participate in this conversation.