Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion caching questions
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Adrian Holovaty  
View profile  
 More options Mar 1 2006, 9:00 am
From: "Adrian Holovaty" <holov...@gmail.com>
Date: Wed, 1 Mar 2006 08:00:55 -0600
Local: Wed, Mar 1 2006 9:00 am
Subject: Re: caching questions
On 2/28/06, fred...@pythonware.com <fred...@pythonware.com> wrote:

> - the admin site is cached too, which makes it a bit hard to use.
> it might be a middleware ordering problem, but I haven't found a
> working combination. any ideas?

Ah, you must be using the per-site cache, right? I'm actually not sure
how the per-site cache would interact with the admin site -- the POSTs
would work, but the GETs would probably be cached. Is that what's
happening?

The best solution to this is to use per-view caches rather than the
per-site cache; that way, you have more fine-grained control over
which types of pages get cached.

> - I would like to explicitly remove pages from the cache, based
> on the URL. is there some public API for this that I haven't found ?

It's possible to interpret this question two ways, so I'll answer both:

* If you're wanting to physically delete a page from the cache, use
the low-level cache API:

from django.core.cache import cache
cache.set('views.decorators.cache.cache_page../some/url/.d41d8cd98f00b204e9 800998ecf8427e',
None)

Note that the cache key contains "/some/url/", which is the URL that
you're wanting to remove from the cache, and the string
"d41d8cd98f00b204e9800998ecf8427e", which is a hash of "empty"
headers. That comes from django.utils.cache.get_cache_key(), which
looks at all the headers that should be considered with respect to
creating the cache key. "d41d8cd98f00b204e9800998ecf8427e" is the hash
for empty headers. Does this make sense? We should probably have a
simple helper function that clears the cache for a given URL, assuming
no headers.

* If you want to prevent a particular view from being cached (when
using site-wide cache middleware), there currently isn't a way to do
that. The tricky problem there is that it would cause a slight
performance decrease: Currently the cache middleware just looks at
each incoming URL, checks the cache for the URL with that key, and
returns the cached page if the key is found. If we were to allow
certain views to be left out of the cache, the cache middleware would
have to do URL dispatching to find out what the associated view is,
then check the view to see whether it should use the cache, then
finally check the cache. The extra overhead of URL dispatching isn't a
huge deal, but it's still kind of counter to caching. Thoughts on this
are welcome!

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.