Seven, Cache
Since Django is a dynamic Web site, every request will go to the corresponding operation of the data, when the program access is large, time is bound to be more obvious, the simplest solution is to use: cache, the cache will be a certain views of the return value saved to memory or memcache, in 5 minutes when someone to visit , the operation in view is no longer performed, but is taken directly from memory or previously cached content in Redis and returned.
There are 6 kinds of caching methods available in Django:
- Development and commissioning
- Memory
- File
- Database
- Memcache cache (python-memcached module)
- Memcache cache (PYLIBMC module)
7.1. Configuration
A, development and commissioning
View Code
B, Memory
View Code
C. Documents
View Code
D. Database
View Code
E, Memcache cache (python-memcached module)
View Code
F, memcache cache (PYLIBMC module)
View Code
7.2. Application
A. Use all stations
View Code
B. Separate View cache
View Code
C, local view use
View Code
MORE: Bash here
Python path--web--2--django-10-Cache