matthewwithanm / django-imagekit

Automated image processing for Django. Currently v4.0
http://django-imagekit.rtfd.org/
BSD 3-Clause "New" or "Revised" License
2.26k stars 276 forks source link

Improve caching #403

Closed vstoykov closed 7 years ago

vstoykov commented 7 years ago

Fixed #399 #402

vstoykov commented 7 years ago

@matthewwithanm What you think about this change?

Instead of doing this:

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': '127.0.0.1:11211',
    },
    'imagkit': {
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': '127.0.0.1:11211',
        'TIMEOUT': 7 * 24 * 60 * 60,  # One week
    },
}

IMAGEKIT_CACHE_BACKEND = 'imagkit'

you can simply do

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': '127.0.0.1:11211',
    },
}

IMAGEKIT_CACHE_TIMEOUT = 7 * 24 * 60 * 60  # One week

Also by default it will cache "forever" there will be 1 day cache timeout if DEBUG = False which is kind of sane default. Or probably I need to check what is the timeout defined in the backend and if there is none then to set 1 day.