If your cache needs are simpler, you can perform caching at the template level. This can provide a tremendous improvement in performance and is easy to use.
- View Offline
- [Narrator] One great method to speed up your site…is to use template caching.…We'll focus on this during this video…but we'll also discuss…some even higher level caching options.…If you have a segment of your template…that can take a while to process…you can use the cache template tag to cache it.…Here's an example from the documentation.…We begin by using the load cache tag.…Then, any part of our template that we want to cache…we simply wrap it in the cache tag.…We pass in two paramenters,…the time in seconds…for it to be cached…and then a name for the key in the cache.…
You can't use a variable name for the key,…so in this case the cache would be just sidebar.…This can be very handy on pages…with a lot dynamic content.…As a matter of fact,…I'll frequently use a cache of 10 seconds…on sites that can have big spikes in traffic.…If I make a change to the website,…it does mean it will take 10 seconds…before the changes show up.…But in most cases,…that's fine.…I've seen a lot of servers melt…because there were hundreds or thousands…
Django is one of the world's leading web development platforms. This Python web framework makes your app building experience smoother, faster, and easier. It is a key feature behind the success of many start-ups across the world, including Instagram and Nextdoor. This course introduces next-level advanced concepts to help you build your own professional-grade Django applications.
Author Kevin Veroneau starts off by explaining how class-based views—a powerful, but often poorly understood feature—work in Django. Then learn how to create custom middleware to help organize frequently used code. Have you ever wanted to build a complete RESTful API? Find out how to do just that, starting with a basic read-only API and then adding key-based authentication to allow the full range of CRUD functionality. Plus, discover how to use model managers and the Q method to make it easier to get the data we need to our views and clients.
For the finishing touches, dive into the details of caching to improve application performance, and then add custom management commands to help automate routine tasks.
- Extending class-based views
- Creating custom class-based views
- Managing your database with middleware
- Creating template filters and tags
- Building a RESTful API
- Modeling advanced database relationships and queries
- Using a model manager for your application