Hi all.

I have a site which makes use of Google's Analytics API which allows me to 
grab the most-viewed content on my site and then show it in various ways 
around the site ("most popular articles" etc). The query against this API 
is slow (takes a couple of seconds) so I've been caching it as described in 
my StackOverflow question about the technique 
here<http://stackoverflow.com/questions/13323150/advice-needed-on-django-caching-strategy>
,

The basic process is this:

   - A cron job hits a URL endpoint every 15 minutes
   - This URL makes the API request and caches the results (for 1 hour, in 
   case the cron ever fails)
   - Meanwhile, my app's views request this data and get served the cached 
   data.
   - In my views, I wrap all usage of this data in named template fragment 
   caches
   - The cron endpoint clears both the high-level cache (which the views 
   call) and the template fragment caches
   - I use a site-wide cache for the entire app.

This kind of works, but occasionally results in blank spaces where the data 
should be -- running the cron job manually has no effect on this. 
Occasionally, experimenting with restarting the server, clearing the app's 
cache and immediately calling the cron endpoints can fix things. After an 
hour or so things tend to work themselves out but it seems that the 15 
minute updates don't actually reflect in the templates.

The StackOverflow advice I got seemed to suggest that using template 
fragment caching *inside* a sitewide cached view should respect the inner 
cache setting, but it doesn't seem to.

Can anyone suggest a strategy for making this work reliably? Every time I 
deploy a new build of the app (and restart the server) it wipes the cache 
and pinging the update URL does nothing. I'm sure my logic is just a little 
wrong.

thanks
Matt

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


Reply via email to