Я не нашел простой способ сделать это. Но это код для ручного кэширования и возврата копии JSON сайта, если параметры GET? Type = json иначе вернут html.
Лучшие зрения:
if request.GET.get('type', None) == 'json' and not request.user.is_authenticated():
#check cache
cached_page = cache.get(request.get_full_path())
if cached_page:
return HttpResponse(json.dumps(cached_page), content_type="application/json")
В нижней части обзора:
if request.is_ajax():
rendered = render_to_string('lootr/deal-item.html', params, context)
if not request.user.is_authenticated():
cache.set(request.get_full_path(), rendered, 60 * 30)
return HttpResponse(json.dumps(rendered), content_type="application/json")