나는 django로 구현 된 REST-ful 서비스를 가지고 있으며 액세스 된 각각의 resource에 대해 접근 가능성이있는 관련 데이터를 캐시하고 싶습니다.프리 캐시 django REST 뷰
예를 들어 ressource http://www.example.com/publication/1280
는 XML 응답을 줄 것이다 :
<publication xmlns="http://www.example.com" xmlns:atom="http://www.w3.org/2005/atom">
<abstract>None</abstract>
<owner>
<atom:link rel="owner" type="application/xml" href="http://www.example.com/user/1">ckpuser</atom:link>
</owner>
<authors>
<author>
<atom:link rel="author" type="application/xml" href="http://www.example.com/author/564">P. Almquist</atom:link>
</author>
</authors>
<comments></comments>
<tags></tags>
<keywords></keywords>
<referencematerials></referencematerials>
<peerreviews></peerreviews>
<fields>
<howpublished>RFC 1349 (Proposed Standard)</howpublished>
<url>http://www.ietf.org/rfc/rfc1349.txt</url>
</fields>
</publication>
그런 다음 나는 능숙 http://www.example.com/user/1
및 http://www.example.com/author/564
과 관련된 캐시 데이터를 전하고자합니다.
웹 서비스 에서처럼 주어진 응답은 데이터 구조의 일종으로,이 전체 응답을 쿼리 세트보다 캐시하는 것이 좋습니다. 쿼리 세트를 캐시하면 ressource에 액세스 할 때마다 템플릿 렌더링 시간이 줄어 듭니다.
좋은 접근 방법입니까? 내가 놓친 게 있니?
이 방법이 옳다면
, 그럼 내가 어떻게 사전 장고'django.middleware.cache.UpdateCacheMiddleware'
및
'django.middleware.cache.FetchFromCacheMiddleware'
에서 제공하는 미들웨어를 사용하여보기를 캐시 수 있을까?