What is caching?
A cache is a saved copy. Imagine you cook a big pot of soup and keep leftovers in the fridge. You do not cook again each time someone is hungry. Drupal does the same. It saves finished pages and serves the saved copy. This is quicker than building the page again.
Drupal 8 is an older version. Newer versions of Drupal use very similar settings.
Before you start
Take a backup of your site. The settings here are safe, but a backup protects you if something looks wrong afterwards.
Steps
- Log in to your Drupal admin area.
- In the top menu, click Configuration.
- Under Development, click Performance.
- Find Browser and proxy cache maximum age. Pick a time, such as 1 hour or more. This tells visitors' browsers how long they can keep a copy of your page.
- Find Aggregate CSS files and tick it. CSS files control how your site looks. Joining many into one makes the site load faster.
- Find Aggregate JavaScript files and tick it. JavaScript files add moving or clickable parts. Joining them helps in the same way.
- Click Save configuration.
Turn on the cache modules
Drupal 8 has two helpers. The Internal Page Cache module saves pages for visitors who are not logged in. The Dynamic Page Cache module saves parts of pages for everyone. Both are usually on already.
- Click Extend in the top menu.
- Search for Internal Page Cache and Dynamic Page Cache.
- Tick them if they are not ticked.
- Click Install at the bottom.
Clear the cache
If you change the site and do not see the change, the old saved copy is showing. Clear it.
- Go back to Configuration, then Performance.
- Click Clear all caches.
- Wait a few seconds, then reload your site.
Quick recap
- A cache is a saved copy that makes pages load faster.
- Go to Configuration, then Development, then Performance.
- Set a cache maximum age and tick both aggregate boxes.
- Keep the page cache modules on.
- Use Clear all caches when changes do not appear.
- Always take a backup first.