Drupal is one the top Content Management Systems used for web designing today. Like every other CMS, Drupal can be slow and consume heavy server resources when not properly optimized. We will begin with what makes Drupal slow:
- Database queries
- Loading CSS and Javascript
- Images which are loaded on your page
- Loading unwanted modules
- Cache settings
You will also want to read:
A Basic Guide to Drupal Website Managemen
Drupal Website Maintenance tutorial
Drupal Website Security Tutorial
How to address "failed Drupal Clean url Test"
Installing a new Drupal website
So what could be done to address this problem. Some useful tips to speed a Drupal website are available:
1. Configuration changes
Make some adjustments to the site configuration settings: see on your site: Administer > Site configuration > Performance
Here you can read the options for page cache, CSS optimization, JavaScript optimization. That standard optimization and database caching can be enough for many sites.
Check the boxes next to "Cache pages for anonymous users," "Cache blocks," "Compress cached pages," "Aggregate and compress CSS files," and "Aggregate JavaScript files."
2. Module Manager - Turn off modules
Turn off update manager module
Turn off any devel modules if you have installed.
Turn off overlay module
Turn off toolbar module, download and install administration menu module instead.
Likewise you should turn off and remove any modules you are not using, since fast loading site is much more important than adding more functionality which is slow.
Boost Module
Enable Boost module. For anonymous users Boost caches your pages HTML files, so your webserver can serve them much more quickly as there will be no database reads. So if majority of traffic is from anonymous users, then Boost is a great module for you. Boost can help you realize a significant performance increase for personal blogs, small business, corporate sites, portals and directories that receive mostly anonymous traffic. For shared hosting this is your best option in terms of improving performance and enhancing your website visitor's experience.
To check site statistics, you can rely on google analytics module.
Also read:
A Basic Guide to Drupal Website Managemen
Drupal Website Maintenance tutorial
Drupal Website Security Tutorial
How to address "failed Drupal Clean url Test"
Installing a new Drupal website
3. Advanced Performance Tuning
Adding Rule to .htaccess file
If you use the mod_deflate rule, you don't necessarily need to check the "Compress cached pages" checkbox on the Performance settings page.
Rules to be added to the .htaccess file (I add this little block of code to the top of the file, just under the "Apache/PHP/Drupal settings:" comments):
##### Midwestern Mac-recommended additions #####
# Use mod_deflate to gzip components
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css application/x-javascript application/javascript text/plain text/html text/xml application/xml
</IfModule>
# Disable ETags (can help if you're using multiple servers, or use cloud hosting)
# see: http_://www.askapache.com/htaccess/apache-speed-etags.html for more info
FileETag None
Also read:
You will also want to read:
A Basic Guide to Drupal Website Managemen
Drupal Website Maintenance tutorial
Drupal Website Security Tutorial
How to address "failed Drupal Clean url Test"
Installing a new Drupal website
Drupal Cache Settings
Caching is a great way to optimize and speed up your website performance.
To enable caching on your Drupal website, you will first need to the Drupal administration area.
Go to Administration > Configuration > Development > Performance.
Unless needed for development, you should always enable "Cache pages for anonymous users". Without it, your Drupal site will have to rebuild every page and will not cache your site. If possible, enable "Cache blocks" as well to increase performance for logged-in users.
Minimum Cache Lifetime
Minimum caching lifetime forces cached content to continue to exist before it can be flushed. If all caches are cleared, any content under the minimum cache lifetime will not be expunged. High traffic sites may want to set this to a non-zero value; when in doubt, set it to none.
Expiration of Cached Pages
This is a key setting. Determines what value Drupal delivers in its max-age header, which is how long the reverse-proxy layer will retain a cache.
Performance is often a trade-off between how fresh your content is, and how fast you want to deliver it to the internet. A good value to start with is 15 mins, but this is something to consider. If you can set it to an hour, that's great for performance. More than a day is usually excessive, since the edge cache will decay over that amount of time in most cases.
Bandwidth Optimization
The "Compress cached pages" setting should not checked, as pages are already compressed with gzip.
On the live environment, make sure to enable "Aggregate and compress CSS files" and "Aggregate and compress JavaScript files" are both checked. This is critical for page render times by reducing the number of HTTP requests and reducing the amount of data transferred.
In Drupal 6, most users should set their cache mode to "Aggressive" to take advantage of the reverse-proxy layer. This is like checking "cache pages for anonymous users": Drupal will "double cache" the pages locally. That can be an advantage as they'll be held until the next cache flush, which can last much longer in practice than the reverse-proxy layer.
Checking "External" prevents this kind of "double caching" by freeing Drupal from the responsibility to store a page that is also being stored at the reverse-proxy layer. Again, this should only be used on sites which don't want the long-term protection of an internal page cache.
Compatibility Warnings
Any module implementing Drupal's hook_boot() or hook_exit() will show up with a compatibility warning on External or Aggressive modes. This is because when Drupal uses Aggressive mode no logic is executed on a successful cache hit. As soon as the CMS detects that the URL being request has a cache, it returns that cache.
Obviously, when the page is cached Externally in a reverse-proxy layer, Drupal is not consulted when cached pages are delivered.
This limits some functionality in Drupal. For instance, the core statistics.module cannot count anonymous pageviews if it isn't being exercised every time a page is viewed. That said, statistics.module is not great for high performance sites.
Minimum Cache Lifetime
As above, this is useful for high traffic sites that don't want to be flushing their caches when every comment is submitted.
Page Cache Maximum Age
As above, this determines the amount of time a cache will be honored in the reverse-proxy layer. Set it as high as you are comfortable.
Block Cache
As above, can help with logged-in performance by preventing re-generation of block elements in sidebars every pageview.
Optimize CSS and JavaScript Files
This setting controls whether or not to compile and cache your CSS and JavaScript files together, speeding up browser-render times significantly. This should always be Enabled.
How to clear cache in Drupal 7
Enabling cache settings in Drupal is a great way to speed things up. But there are times you add a new artcle and would want to clear the cache settings in other to view your new publication or changes. That is when you will manually want to clear the Drupal cache. These steps will help you through a step-by-step process.
Deleting the cache content in Drupal 7:
Log into your Drupal 7 admin dashboard.
On the top menu bar, locate the Configuration option and click on it.
This brings you to the main Configuration category screen. Find the subcategory named Development and click on the Performance link.
Once on the Performance screen, look to the button on the screen at the top named Clear All Caches. click. that.
You have now cleared out all caches in Drupal 7
How The Drupal Page cache Works
The internal page cache feature of Drupal 7 is decent for most sites to start with. Drupal broadcasts stored compressed cached pages to anonymous users, resulting in faster internal page assembly. Essentially, Drupal would not have to rebuild a page each time it is viewed until the cache reloads. This useful feature is on the Administer > Performance page. To activate it: click the Normal radio button and choose at least 1 minute under the minimum cache lifetime. I recommend enabling the Page and Block cache options as well.
Compressing CSS and JS files
Now that Drupal can internally cache pages you will see processing of requests faster for new users, but you continue optimizing by compressing all the external styles and script files that load for each module. Each module adds a new <link> tag for its CSS in your <head> code, the same goes for each JavaScript file needed by a module. To help speed up page loads even more, Drupal can compress all these styles and scripts into a single set of files (one for every CSS style, and one for every JS file on a page). This will speed up page delivery and rendering.
You can enable CSS and JS compression in the Bandwidth Optimizations area of the Performance page. Pages really load fast when this setting is turned on, but be warned: if you're changing a theme file and leave this feature on, your changes will not appear until the cache clears on its own or you click the Clear cached data button at the bottom of the Performance administration page.
Final Notes
Optimizing your Drupal website will increase its performance. A good way to speed up your website and secure it from web hosting penalties associated with server load issues is effective optimization.
There are several steps that you will follow to achieve good optimization for your Drupal website.
First, you should enable the caching system on your Drupal application. In order to do this, login as administrator and go to the Administer -> Site Configuration -> Performance menu. In it, set the values of Caching Mode to "Normal" and Block Cache to "Enabled". Then, click on the "Save configuration" button at the bottom of the page.
Next, you need to disable all the modules/blocks that you are not actually using. To do this, go to the Administer -> Site Building -> Modules menu. Note that the enabled modules have a check in the "Enabled" column. Remove this check for all the modules you want to disable and then click on the "Save configuration" button at the bottom of the screen.