How it works...
As you will see later in the Using database query expressions recipe in Chapter 10, Bells and Whistles, the detail view of the viral video shows the number of impressions by authenticated and anonymous users. If you access a viral video (such as at http://127.0.0.1:8000/en/videos/1/) and refresh the page a few times with caching enabled, you will notice that the number of impressions changes only once a minute. This is because each response is cached for 60 seconds for every user. We set caching for the view using the @cache_page decorator.
Memcached is a key-value store and it uses the full URL by default to generate the key for each cached page. When two visitors access the same page simultaneously, the first visitor's request ...
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.
Read now
Unlock full access