On Nov 14, 2017 3:04 PM, "Matthew Pava" <matthew.p...@iss.com> wrote:

We can download PDFs in our project.

We start out generating the PDF on the server.  We read the contents of it
into a variable to put it into memory.  Then we delete the file on the
server (it’s still in memory), and the response is itself the PDF document.


Note that this strategy has two potentially negative side effects:

1. The original file is no longer available for a second attempt to
download in the event the first attempt fails. This may be fine if the file
is generated every time as part of the request.

2. Loading the file in to memory is usually find for smaller sites, but
high traffic sites can run in to memory resource issues.

You can also have a cron job delete files every so often based on their
age, rather than deleting them as part of the immediate response cycle.
That would save on memory, if that's a concern.

-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWOUxKzDDbLezw23ABE1Q%3DapYVJR3gU4TAtvEb0RvGFOQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to