I am trying to get Etags working in Django - so that if a page has not been updated (and the client has already seen the page) it is returned by the client's browser rather than rendered by django.
The code below is proof of concept. However, it only partially works, and that's why I'm asking for help. When the client first connects the code correctly renders the page and returns an ETAG header. On the next request, the browser correctly sends the "If None Mach" request header with the ETAG details. The code correctly returns the 304 respose and the client displays the page from the browser's caache. So far so good. However, on the third request, it seems that the browser does not send a "If-None_match" request header, so the etag is not found and the whole page re-renders from the server. Is there something else I need to configure? Or something I am doing wrong? Cheers MerMer def etag_test(request): etag = "TestEtag12345" if etag == request.META.get("HTTP_IF_NONE_MATCH"): # Check to see if request has matching etag return http.HttpResponseNotModified() # if etag matches send a 304 reponse, so browser uses client cache html="<html><body>This is a test of ETAG</body></html>" #Finally, add in the ETag to the new response we're returning. response = http.HttpResponse(html) response["Etag"] = etag # add Etag header to respone return response --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---