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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment