Boost your Drupal website
Boost is an amazing Drupal module that can dramatically improve the page speed performance. This can improve the experience of visitors and help a web site cope with unexpected surges in traffic.
One of the major problems with Drupal is the number of database queries required to construct each page when a user visits a web site. This is cut down hugely when you enable the built in page caching. But cached page data is still stored in the database, so the site still needs to call the database.
This is especially problematic if you are running a Drupal site on shared hosting. You may notice that your web site is quite sluggish and page load speeds are a bit on the slow side.
Enter Boost - The Solution
One possible solution is to upgrade to VPS or dedicated hosting. Essentially you are throwing more resources at the web site to help it cope. However, many of us can not afford that.
Boost is the ideal solution for those on shared hosting. It cuts out the need for database calls entirely and instead serves just static HTML pages to users.
How Boost works
Instead of caching page data in the database, Boost creates static HTML pages. This happens when the first user to visit a page after cache has expired. So for that user, the page download speed will still be slow as the site still has to call the database to create the page. But every user who visits that page (and any other page that has been cached) after that point will be served a static HTML page. There are NO calls to the database. In fact, the page serving process does not touch Drupal at all!
When a page is cached as a static HTML page, a comment is added to the bottom of that page with the expiry time. That is calculated from the "minimum cache lifetime" that is set in site configuration -> performance. A page that is past its expiry time is stale. When cron is run, any stale (expired) HTML pages will be deleted. Then when the next user visits a page that has been deleted, a static HTML page will be created again.
It all hinges on cron
You must run cron on a regular basis for this to work since stale pages will not be deleted without it. All static HTML pages that exist in the cache folder will be served to users even if they have expired. Therefore, you need to set cron to run in order to delete them.
The regularity of the cron runs is up to you and depends on how often content changes. If you have a site that has content added throughout the day, you might want to run it hourly. For this site, I actually don't run cron automatically. Instead, I manually run cron when ever I had new content. That way, I can be sure that pages are always up to date.
Boost is for Anonymous users only
An important point is that Boost only works for anonymous (non-logged in) users. If a user logs in, it will by pass Boost and serve pages as per the normal Drupal process. This is very common with any caching module since logged-in users are generally receiving dynamic pages that will change from user to user. I will be explorer ways to improve the performance for logged-in users in a later post.
If you have a web site that has slow page load speeds, Boost may be the perfect answer. It will create static HTML pages and by passes the database and Drupal process for most anonymous users.
If you liked this, you'll love my book, Master Drupal Module Development.
"..the must have drupal developers book"
Feeling stuck with Drupal 8 module dev?
Get the free 7 lesson course that will help you get started today without feeling overwhelmed.
- Create Drupal modules with just a few commands using the Drupal Console
- Create custom pages
- Create custom blocks
- Create admin forms
- Demystify routers and controllers
- Bonus material