Hi,

You're trying to cache a pdf file/attachment? why? What's the purpose
of trying to do it that way? Why don't you just send it to the client
when they ask for it?

Also, there's no way on the server to 'force' content to be cached on
the client. The browser has to specifically allow it. All I can think
of is the browser needs to set if_modified_since headers in the
request for the server to respond with a 304, but I've never tried to
cache a pdf file or attachment.

On Apr 27, 12:44 am, Oliver Andrich <oandr...@googlemail.com> wrote:
> Hi,
>
> I have a problem getting the browser to cache the data returned by my view.
> The basic idea behind this is, I want to download the data via ajax to
> provide a progress dialog and afterwards I set document.location.href to the
> same url and use the cached data. last_modified sets the last modified
> header as expected. The creation also behaves like expected. The line
> "document.location.href = href + '?timestamp=' + timestamp" creates a second
> GET for my view, but I get a 200 http code instead of a 304. And if I look
> at my browser cache contents, I can see, that my data is not cashed at call.
> The caching even doesn't if I open the url in the browser directly.
>
> Can I force the browser to cache my data?
>
> Best regards,
> Oliver
>
> My Django view:
>
> @login_required
> @redweb_view
> @last_modified(last_modified_func)
> def show_pdf(request, page_id, quality):
>     page = Page.objects.get(pk=page_id)
>     with create_client_from_request(request).create_session() as s:
>         pdf_data = s.print_element(page_id, image_quality=quality)
>     response = HttpResponse(mimetype='application/pdf')
>     response['Content-Disposition'] = 'attachment; filename=%s.pdf' %
> page.name
>     response.write(pdf_data)
>     return response
>
> My Javascript code:
>
>             var timestamp = new Date().getTime();
>             $.get(href + '?timestamp=' + timestamp).success(function() {
>                 document.location.href = href + '?timestamp=' + timestamp;
>             });

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to