3.4. Cache (optional) — machado 0.1.0 documentation

# 3.4. Cache (optional)

The machado.urls are pre-configured to enable caching. You just need to enable Django’s cache framework following the official instructions.

Example

Include the following in the settings.py:

    CACHES = {
        'default': {
            'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
            'LOCATION': 'machado_cache_table',
        }
    }
    CACHE_TIMEOUT = 60 * 60  # 3600 seconds == 1 hour

Create the cache table:

    python manage.py createcachetable

Clearing the cache table

It is a good idea to clear the cache table whenever you made changes to your machado installation. For this intent, install the django-clear-cache tool https://github.com/rdegges/django-clear-cache

    pip install django-clear-cache

Then modify your settings.py file to add clear_cache:

    INSTALLED_APPS = (
    # ...
    'clear_cache',
    )

Then to clear the cache just run

    python manage.py clear_cache