Hi...

For PyLucid i made a simple cache middleware [1] simmilar to Django per-site cache middleware [2]. But i doesn't vary on Cookies and don't cache cookies. I simply cache only the response content.

Of course: This doesn't solve the problem if "csrfmiddlewaretoken" in content.

Here some pseudo code from [1]:
-----------------------------------------------------------------
    def process_request(self, request):
        if not self.use_cache(request):
            return

        response = cache.get(cache_key)
        if response is not None:
            return response

    def process_response(self, request, response):
        if not self.use_cache(request):
            return response

        # Cache only the raw content
        response2 = HttpResponse(
            content=response._container, status=200,
            content_type=response['Content-Type']
        )

        patch_response_headers(response2, timeout)

        cache.set(request.path, response2, timeout)

        return response

-----------------------------------------------------------------

[1] https://github.com/jedie/PyLucid/blob/master/pylucid_project/middlewares/cache.py
[2] https://docs.djangoproject.com/en/1.3/topics/cache/#the-per-site-cache


Mfg.

Jens D.

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

Reply via email to