Polyglot,

user asks server via XHR. Server does the processing and sends back various data items (logfile + pdf) in a blob tar/zip-like archive or base64-encoded data within a JSON. User's browser runs JS which exctracts logifile and PDF and then sets up a dynnamic client's-browser-based download link for both, see, e.g., https://www.alexhadik.com/writing/xhr-file-download/. The difference to the already posted answers Re^3: Can two separate responses be sent to the client's browser from Perl, such as via fork{}? and Re^3: Can two separate responses be sent to the client's browser from Perl, such as via fork{}? is that latex file has been processed and data has already been fetched to the browser and the browser's JS creates download links for something that has already arrived. I.e. no temp files in server to wait for, no watching over server-running processes, etc.

If you have managed to work out a setup whereas the server robustly processes the latex file or fails within some set time out which your client can tolerate and always responds back via a json containing logfiles, errormessages and possibly a PDF, then this is can be OK. Latex can take, say, 40 seconds to process a file. Usually 15secs (my use-cases). This is the time a client must wait for data from its request. Is this OK? can the connection be broken in that interval? if yes, this means failures which the client will click and click and click to run again, your server is at risk of bombing.

Bottom line, AFAIC, think this over. 1) you, perhaps, need to let the server know that a second request from an impatient client is already being handled (md5 of latex source file plus client ID?). 2) Does latex processing takes long time which risks broken client-server connection? In this case you need to follow what afoken and fletch suggested. 3) Is it a fast processign? then just process and send back a JSON of PDF+logfiles. JS handles it and creates download links (for pdf) and/or displays logiles in a div, dynamically. 4) cache of produced pdf files for not processing latex again? requires storing md5 of latex source.

note: "md5" is used generically for a hash.

Some edits within 10 mins

bw, bliako (with a bitten glo(tt|ss)a)


In reply to Re: Can two separate responses be sent to the client's browser from Perl, such as via fork{}? by bliako
in thread Can two separate responses be sent to the client's browser from Perl, such as via fork{}? by Polyglot

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.