Skip to Content
Django 3 Web Development Cookbook - Fourth Edition
book

Django 3 Web Development Cookbook - Fourth Edition

by Aidas Bendoraitis, Jake Kronika
March 2020
Intermediate to advanced
608 pages
17h 17m
English
Packt Publishing
Content preview from Django 3 Web Development Cookbook - Fourth Edition

How it works...

Just like with Memcached, we set caching for the view using the @cache_page decorator. So, each response is cached for 60 seconds for every user. A viral video detail view (such as the one at http://127.0.0.1:8000/en/videos/1/) shows the number of impressions by authenticated and anonymous users. With caching enabled, if you refresh the page a few times, you will notice that the number of impressions changes only once a minute.

Just like Memcached, Redis is a key-value store, and when used for caching, it generates the key for each cached page based on the full URL. When two visitors access the same page simultaneously, the first visitor's request would receive the page generated by the Python code, and the second one would ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Django 2 Web Development Cookbook - Third Edition

Django 2 Web Development Cookbook - Third Edition

Jake Kronika, Aidas Bendoraitis

Publisher Resources

ISBN: 9781838987428Supplemental Content