Tuesday. 8:15 pm. Time for a pint

Ot it would be if I wasn't looking after a pub while the incumbents are away for a week

It's a little quieter now. For some it has been emotional. For me it has been difficult to debug my new bright idea - a pseudo asynchronous process. Exciting? Probably not. Genius? Maybe - or maybe just obvious - they are often difficult to distinguish.

The problem

Rendering a PDF as a JPEG at a reasonable quality can be a bit slow. If the process is triggered as part of the page request, it can look like nothing's happening for a few seconds - long enough for it to feel as if there might be a problem.

There are a few options. A scheduled script could take care of things without anyone noticing. That's not very interactive though. I'd prefer to be able to interact with a PDF, parse its pages and flick through them, rendering image version of each page as a go. Some sort of asynchronous back-end script could hand-off the slow bit to allow the page request journey to reach its end more timely. Having looked at that, I'm not keen.

Let JavaScript deal with it

The simple/genius solution is to skip the chunky process while dealing with the page request, and send some JavaScript which the triggers another request after the page has loaded client-side – a simple request that just triggers the slow server-side process. JavaScript is quite happy to silently wait for a response and either tell the user that something has happened, or reload a placeholder with a newly created image.

I probably haven't explained that very well, but hey, it's been a long day. A demo? I'm not sure I want to set up something that runs processor-intensive server-side processes for demonstration processes.

[ miv : 1650 ] typomania.technology