Changeset 110

Show
Ignore:
Timestamp:
11/09/09 18:17:33 (10 months ago)
Author:
max
Message:

Modified behavior of automated full page cache invalidation to allow for more graceful handling of potential dogpiling effects.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/courant/core/caching/models.py

    r108 r110  
    66from django_extensions.db.fields import ModificationDateTimeField 
    77from django.conf import settings 
     8 
     9# number of seconds to wait before fullpage cache is deleted when expiring a template fragment on that page 
     10FULLPAGE_CACHE_REFRESH = 10 
    811 
    912class CachedObject(models.Model): 
     
    2730                        urls.append(obj_cache.url) 
    2831 
    29                 # delete caches for all marked URLs 
    30                 # since full-page caches don't use anti-dogpiling, we delete the caches themselves 
     32                # for full page caches, reset them with a short expiration time. 
     33                # this should hopefully allow for a non-anonymous user to load 
     34                # the page and create template fragment caches, so that when the 
     35                # first anonymous user hits the page, it doesn't have to do much 
     36                # processing to create a new full-page cache (since the fragments are 
     37                # all cached), and thus avoid potential dogpiling 
    3138                for url in set(urls): 
    3239                        key = "%s-%s" % (settings.CACHE_KEY_PREFIX, url) 
    33                         print "Deleting cache: %s" % key 
    34                         cache.delete(key) 
     40                        fullpage_cache = cache.get(key) 
     41                        if fullpage_cache: 
     42                                cache.set(key, fullpage_cache, FULLPAGE_CACHE_REFRESH) 
    3543        except: 
    3644                pass