php - The right way of generating pdf, xls, png files in webapp -
i have generate reports of various file type(excel, pdf, png), based on inputs of web application. application written in php on apache webserver.
atm, when users visit reports section, trigger event checks if there submitted new data in database , based on info, new report files generated. makes user wait until files generated (3-10seconds), not approach @ need advice can give me.
of course depends on application , system, typically have cron job executes php script generate reports periodically. output saved filesystem or in database. way reports generated once (rather each time user tries download them) , generated when needed (your script check if needs generate report based on whatever change criteria have, or set generate whole new reports periodically). keep simple call current web page wget or curl, , create new page on webserver downloading saved reports.
the problem approach users might download "stale" reports (data has changed reports haven't been updated). if issue approach keep php script running in background checking modified data , generating reports needed.
another approach continue generating reports when users attempt download them, cache results. again using own application-specific criteria check if cached report enough immediate download, or generate new report , cache it. combine first approach periodically generating new reports, if user attempts download report out of date generate new 1 (making user wait 3-10 seconds).
ultimately depends on system , application.
Comments
Post a Comment