Caching with Django
Caching is considered one of the necessary evils of computer science. It helps to attain performance gain, but it also makes the system complex. One of the most important complexities in computer science is invalidating the cache. In this section, we will learn how caching is implemented in Django and also how we can improve the overall caching experience for developers using Django and DRF.
Django provides different types of caching strategies out of the box:
- Local memory caching: The data is cached in the application memory itself.
- Database caching: Django would store the cached results in the database itself.
- Filesystem caching: Cached entries are saved as files on the file system.
- Memory database-based caching: Django supports caching databases such as Memcache and Redis to be used in the project. We shall learn how to integrate Redis into our Django project in this chapter.
- Custom caching: Developers can also write a custom backend...