Caching in Divio Cloud applications¶

See also

Caching in Divio Cloud applications will typically make use of Django’s own caching framework.

Caching options¶

Database caching¶

Our default cache backend is Django’s database caching; all DivioCloud projects are set up with this configured and ready to use.

This is a fast, scalable option, and is suited to most needs.

Database caching is shared by all instances of an application server.

Local per-instance caching¶

Warning

Per-instance caching options are not suitable for django CMS sites,which require synchronisation of data across instances for correctoperation.

Depending on the needs of other applications, you may or may not find thatthese options are suitable.

Per-instance caching options cache data for a particular instance of the cloudapplication server. This means that if your project is running on multipleserver instances, they will not share the caches.

For the same reason if you SSH into a Cloud server and do:

  1. from django.core.cache import cache
  2.  
  3. cache.clear()

in a Python shell, you will only clear the cache in the container you have juststarted up.

Options are:

Third-party caching backends¶

Other backends, such as Redis (a popular open-sourcedatabase) can be used as caching backends for Django.

If it suits your needs, you can procure a Redis or other caching instance froma provider and use it with your Divio Cloud project.

Caching in django CMS¶

The Aldryn django CMS addon applies caching rules by default, via theCMS_CACHE_DURATIONS setting.

Control over caching settings is exposed in the Divio Cloud Control Panel in the configurationoptions for Aldryn django CMS.

Defaults are to cache content for 60 seconds and menus for one hour.

It is often convenient to disable this while developing or working intensively on content. Adding:

  1. import os
  2. env = os.getenv
  3. STAGE = env('STAGE', 'local').lower()
  4. if STAGE in {'local', 'test'}:
  5. CMS_PAGE_CACHE = False
  6. CMS_PLACEHOLDER_CACHE = False
  7. CMS_CACHE_DURATIONS = {
  8. 'menus': 0,
  9. 'content': 0,
  10. 'permissions': 0,
  11. }

to the project’s settings.py will disable all caching in the CMS in the local and Testenvironments.

原文: http://docs.divio.com/en/latest/reference/caching.html