
Quick Contact
Python Tutorial
- What is Python?
- How to Install Python?
- Python Variables and Operators
- Python Loops
- Python Functions
- Python Files
- Python Errors and Exceptions
- Python Packages
- Python Classes and Objects
- Python Strings
- PostgreSQL Data Types
- Python Generators and Decorators
- Python Dictionary
- Python Date and Time
- Python List and Tuples
- Python Multithreading and Synchronization
- Python Modules
- What is Python bytecode?
- Python Regular Expressions
Python Panda Tutorial
- Python Pandas Tutorial
- Python Pandas Features
- Advantages and Disadvantages of Python Pandas
- Pandas Library In Python
- Pandas Series To Frame
- Python Dataframeaggregate and Assign
- Pandas Dataframe Describe
- Pandas Dataframe Mean
- Pandas Hist
- Pandas Dataframe Sum
- How to convert Pandas DataFrame to Numpy array
Python Selenium
- Selenium Basics
- Selenium with Python Introduction and Installation
- Navigating links using get method Selenium Python
- Locating Single Elements in Selenium Python
- Locating Multiple elements in Selenium Python
Python Flask Tutorial
Python Django
- How to Install Django and Set Up a Virtual Environment in 6 Steps
- Django MTV Architecture
- Django Models
- Django Views
- Django Templates
- Django Template Language
- Django Project Layout
- Django Admin Interface
- Django Database
- Django URLs and URLConf
- Django Redirects
- Django Cookies and Cookies Handling
- Django Caching
- Types of Caching in Django
- Django Sessions
- Django Forms Handling & Validation
- Django Exceptions & Error-handling
- Django Forms Validation
- Django Redirects
- Django Admin Interface
- Django Bootstrap
- Ajax in Django
- Django Migrations and Database Connectivity
- Django Web Hosting and IDE
- Django Admin Customization
- What is CRUD?
- Django ORM
- Django Request-Response Cycle
- Django ORM
- Making a basic_api with DRF
- Django Logging
- Django Applications
- Difference between Flask vs Django
- Difference between Django vs PHP
Numpy
- Numpy Introduction
- NumPy– Environment Setup
- NumPy - Data Types
- NumPy–Functions
- NumPy Histogram
- numPy.where
- numpy.sort
- NumPyfloor
- Matrix in NumPy
- NumPy Arrays
- NumPy Array Functions
- Matrix Multiplication in NumPy
- NumPy Matrix Transpose
- NumPy Array Append
- NumPy empty array
- NumPy Linear Algebra
- numpy.diff()
- numpy.unique()
- numpy.dot()
- numpy.mean()
- Numpy.argsort()
- numpy.pad()
- NumPyvstack
- NumPy sum
- NumPy Normal Distribution
- NumPylogspace()
- NumPy correlation
- Why we learn and use Numpy?
Tensorflow
- Introduction To Tensorflow
- INTRODUCTION TO DEEP LEARNING
- EXPLAIN NEURAL NETWORK?
- CONVOLUTIONAL AND RECURRENT NEURAL NETWORK
- INTRODUCTION TO TENSORFLOW
- INSTALLATION OF TENSORFLOW
- TENSORBOARD VISUALIZATION
- Linear regression in tensorflow
- Word Embedding
- Difference between CNN And RNN
- Explain Keras
- Program elements in tensorflow
- Recurrent Neural Network
- Tensorflow Object Detection
- EXPLAIN MULTILAYER PERCEPTRON
- GRADIENT DESCENT OPTIMIZATION
Interview Questions & Answers
Django Caching
In today’s era of web development, every user wants their requests on the website to be responded ASAP. There are certain methods which will make your website faster. Faster the website, greater the users it will attract.
What are Dynamic Websites?
Dynamic websites are a collection of webpages which are generated dynamically.
Simple! So, why is it a big deal? because that generation of webpages means every page requires some processing. Servers aren’t cheap and so is their CPU time. Their limitation is that they need more CPU time to generate those webpages. More processing means more time added in response time, which makes the response of website slow. It is slow enough that users get annoyed.
Dynamic websites generate highly personalized webpages. They come with tons of features. Some examples of websites are Spotify, Google, Facebook, Instagram, etc.
A very good example can be Google Feed. The personal news feed on google app is generated dynamically. Its contents change in every 2-3 hrs. The updating process takes time if you refresh.
Most of the websites on the Internet are becoming more and more dynamic and that makes it necessary for web developers to create faster websites. Caching comes in there. It provides a cost-effective and working solution. The more processing time a webpage takes, the more caching can improve its performance.
There are other solutions as well:
- Installing better server hardware
- Installing the better server software
- Improving database
- Writing efficient code, etc.
All these solutions require time and some resource. But, caching doesn’t require that much time to implement. Just learn from this tutorial and implement it easily.
What is Caching?
Caching is the process of storing recently generated results in memory. Those results can then be used in future when requested again.
The computer memory works in a similar manner. CPU stores some files in the cache Memory. And, when CPU needs them again it looks for those files in Cache Memory first. Since Cache Memory is fast, the processing time improves. We will be implementing something similar on our server.
Caching on Server
Suppose we have a dynamic website. When a user request for some page:
-
A Dynamic Page generates
The requested dynamic page generates. Since it is generating for the first time, it will take a little bit longer. The CPU will process the page and that time will add to the response time.
-
A webpage serves and gets stored in Cache Space
Now, before serving this page to the client, it stores in Cache Space. Cache Space is a location where you temporarily store data to be retrieved for later use. Then it will serve to the client.
-
Multiple users request for the same page
Maybe, there are other clients requesting the same page. So, instead of generating webpage again we use the resource in Cache Space.
-
Server responses with Cached Webpage
Since we have that same resource stored in our Cache Space, our server will respond to these users with that webpage. The response time will decrease by the processing time. This makes the response much faster.
-
Deletion of data in Cache Space
Cache Space store copies of data. To keep the redundancy of data minimum, we delete the Cache Data after some time. This makes room for new Caching Data and the cycle goes on.
Some important points:
-
CPU time of Webpage
We discussed about dynamic websites in the previous section that caching subtracts processing time from response time. So, if our website serves static pages, there may not be any improvement. Therefore, caching is mostly used for dynamic webpages.
-
Memory type used for Cache Space
Caching space is also a factor to improve speed. There can be three types of Cache Spaces:
- Main Memory
- Database Tables
- File-System or local directories
As we can see, the main memory caching is the fastest of all. Faster the memory, better is the response time.
-
Expiry time of cached data
Cached data should exist for a certain period of time. If the data gets deleted too early, there will be no utilization of caching. Also, if the data doesn’t get deleted, then it will waste cache memory.
It depends on the type of resource and its demand by the users.
Caching in Django
Caching is important for a dynamic website. Since Django is a dynamic framework, it comes with built-in options for you to manage your cache.
Django allows caching on different caching spaces as well as on different parts of a website. There can be certain parts of the website which can demand more CPU time and granularity to implement caching on them individually. This makes caching efficient.
We learned about different caching spaces in the previous section. Now, let’s implement caching on all of them.
Setting-up Caching System
We will be setting up different caching frameworks or spaces. Your system may only need one so implement one, which fits your requirements with given constraints.
What is Memcached Framework?
Memcached is a memory-based cache framework. This software takes a certain part of the main memory and converts it to Cache Space. It handles that efficiently so the main memory is never completely full.
When a request comes to the server, it will first look in Cache Space. Memcached provides faster response since the main memory is fastest of all. If the resource is not present in Cache Space, the server generates that resource. That is again stored by Memcached, if the developer has cached it.
The Memcached framework can work on multiple servers. We can change the LOCATION key and it can have different values, like the IP addresses of other servers.
When Memcached is expanded to multiple servers, it considers all of them as a single server. This approach reduces data-redundancy to a certain level. This is also one of the reasons Memcached Caching is preferred over other types of Caching.
The Memcached framework is one of the most popular choices for caching. It is used by almost all the servers. It can be difficult to implement on Windows/ Mac as it is designed for Debian/ Ubuntu Operating System, which is server OS.
To use Memcached framework in Django:
- Install Memcached framework on your system
- Install Python connectors for Memcached Framework
- Edit our Settings.py file
As mentioned earlier, installing Memcached framework on Windows/ Mac OS is difficult. If it is installed then proceed. And, if you have Debian/Ubuntu OS, then there are no issues.
Apply now for Advanced Python Training Course