I just did some local debugging, and notice something interesting. The cache key appears to be generated based on a hash of the request headers.
This means that visiting the same page in two different browsers will generate 2 unique keys, which means that the cache isnt used. For example, on my site, loading /about/ Here are the cache keys generated: Firefox views.decorators.cache.cache_page../about/.d08052b9800d6ec1d568dc223a1312f3 Safari views.decorators.cache.cache_page../about/.d41d8cd98f00b204e9800998ecf8427e So, if i visit the page first in Firefox, the page will be dynamically generated. If I then visit the page in Safari, the page will once again by dynamically generated (and not pulled from the cache). If I am understanding this correctly, then it has a couple of implication: 1. it will be very difficult, if not impossible to remove a specific path / page from the cahche 2. cacheing isnt that efficient since it is per-page / per headers, and not just per page. Anyone have any input on this? I realize that there is a good chance that I am missing something obvious. One simple solution would be for me to change the django source to just generate a key based on the hashed path, but I dont want to branch the django source. mike Mike Chambers wrote: > Upon looking at the source, it looks like I am using an out of date way > to generate the cache key: > > http://code.djangoproject.com/browser/django/trunk/django/utils/cache.py > > Does anyone have an example of how to generate the key from just the > page path? i.e. > > /about/ > > The : get_cache_key API takes a request, but I need to delete the cache > for a specific page (which isnt the one being requested). > > mike > > Mike Chambers wrote: >> I am using memcache for my site, and it is working well except for one >> issue. >> >> When a user enters a comment, I redirect them to the page they >> commented from. However, since the page is cached they dont see the >> comment. >> >> My first fix was to just appened a query string to the URL, but this >> then means other people dont see the content until the cache expires. >> >> So, now I have code that removes the item from the cache before I >> redirect to the page: >> >> -- >> from urlparse import urlparse >> ref_uri = urlparse(request.META['HTTP_REFERER']) >> key = >> 'views.decorators.cache.cache_page..%s.d41d8cd98f00b204e9800998ecf8427e' >> % (ref_uri.path) >> from django.core.cache import cache >> cache.set(key, None) >> >> return HttpResponseRedirect(request.META['HTTP_REFERER'] + "#c_" + >> str(comment.id)) >> -- >> >> The key ends up looking like: >> >> views.decorators.cache.cache_page../about/.d41d8cd98f00b204e9800998ecf8427e >> >> >> I got the key code from: >> http://groups.google.com/group/django-users/browse_thread/thread/500d8cebe1f0c4e1/b077ec2e97697601?lnk=gst&q=cache+delete+page#b077ec2e97697601 >> >> >> >> Anyways, this doesnt work, and when I am redirected to the page, I am >> still getting the cached version. >> >> Does anyone see what I might be doing wrong? Am I removing the page >> from the cache correctly? >> >> mike --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---