Caching in Drupal
What is caching and how it works in Drupal?
What is Caching?
Caching is a technique which saves static versions of a dynamic website into folders or even in the database, in order to reduce the resources usage in the server. Most caching mechanisms focus to free database usage because SQL is usually what makes websites linger, especially when the datasets are increased.
The usual technique is to store whole pages or page parts in static files or in the database for a certain time. For as long as there are static files, these are made available for your website's visitors and there are not any other additional operations for calculations and data extracts from the database, or running high-level language code (php, jsp, asp etc.) in order a page to be served from the server. What works is essentially the web server which serves the already made html without burden the server with sql queries and programming calculations.
Caching technique is supportive and important for the functioning of many websites, but it can not be applied everywhere and uncontrollably because there are many websites (or sub-site operations), which serve absolutely dynamic content to their visitors.
When there is a need for absolute dynamic content then avoid caching or enable it in all the different sections of the website that they do not need to be dynamic. Usually caching is avoided at parts of the website where the user has to be logged in (if there is a user area) because from that point and after the user sees content specific only to him.
When a website is made with custom code, then it is in the discretion and the experience of the programmer to implement caching techniques to the dynamic pages by caching individual sections of the page to intermediate static files and dynamically drawing only the pieces that differentiate the page for the user who visits it.
In contrast, when the code is based on ready software, it is customary to use ready caching structures which will inevitably will not do so specialized functions, since it must be able to accommodate many types of installations for the same platform. Rarely it is possible for a developer to specify the caching of a ready application, because the need of compatibility with future updates of the application but mainly for implementation costs of the more specific structures in an application with vast codebase.
Caching in Drupal
Drupal caching concerns only the users who have not logged into the website. When someone logs into then sees the fully dynamic website and is exempted from caching mechanisms.
The above implementation of caching provides a great potential for websites with large traffic of unregistered (anonymous) users because all these visitors are served with the cached pages and that does not significantly burden the server.
Instead when most users use the page after they login (eg. facebook) then the above logic does not work. In such scenario the programmer should specify the caching in individual sections of the website in order to decongest the usage of the processor and memory on the server. Drupal allows the programmer to create special code to write his own modules and implement such hybrid structures, which will operate partly as static and partly as dynamic.
If you want to enable the general Drupal caching you can follow the below simple steps:
- Login as administrator and go to Site Configuration > Performance.
- Then under Caching mode: select Normal and under Block cache: select Enabled (This settings are recommended for most websites).
- Finally click Save configuration to save your changes.
To evolve the caching of Drupal you can use additional modules that you will find on the official website of the Drupal community or even contact a Drupal Specialist, who will have the training and the freedom to implement specific structures in your website.