The Peakhour Purge module transparently enables full page caching on the Peakhour EDGE for Drupal 8/9. Once installed, Drupal will issue Cache Tag headers on page responses, along with Cache Control headers for cacheable pages. The module extends the Drupal Purge module to send Peakhour flush by tag requests when content is changed in the Drupal Admin.
The module can be obtained from the Peakhour Purge module page on the Drupal website.
You will need a Peakhour account to be able to utilise this extension. If you don't already have one you can sign up here, installation of the extension does not automatically create an account for you.
All new signups get a free trial. Once you have your account the only other change you need to make to activate our acceleration and web application firewall is a DNS change. Do not enable the module until you have successfully configured your domain behind the Peakhour service.
The Peakhour Purge module requires the Drupal Purge module, make sure you install Purge first using composer:
composer require drupal/purge
composer require drupal/peakhour_purge
Unzip the module under the Drupal /modules/contrib directory
Click on Configuration in the top level menu, then on Performance under the Development section. On the resulting page choose a cache TTL (1 year is recommended) from the dropdown under Browser and proxy cache maximum age and click Save Configuration
Then click on the Purge tab. Then click on the Add Purger button. Peakhour should be the only option, but if you do have multiple Purge modules installed, then select Peakhour and click Add.
Then click on the down arror next to Peakhour and click 'Configure', a pop up will be displayed with the following fields:
Fill in these fields (including ticking Enabled) and click 'Save Configuration'
By default, Drupal adds a Vary: Cookie header to the server response so that users that log in will skip the cache. However, this can result in very poor cache hit rates if you use third parties that set their own cookies, eg Google Analytics, an AWS load balancer, etc. Peakhour allows you to skip the cache if a given Cookie is set, so we can remove the Vary and set the skip to allow for much higher hit rates.
To remove the Vary: Cookie header, go to your settings.php under your Drupal installation. This is usually under:
DRUPAL_HOME/web/sites/default
You may have to copy the default.settings.php to settings.php if you don't have a settings.php in the directory. Open the file and uncomment the
# $settings['omit_vary_cookie'] = TRUE;
line and make sure it is set to true.
If you have done step 4 and removed the Vary: Cookie header you will also want to configure Peakhour to skip its full page cache if a Drupal session cookie is set. To do this log in to the Peakhour admin, administer your domain, then choose 'Edge Rules' from the left menu.
Add a new rule with the following:
IMPORTANT This example assumes you are using a standard Drupal 8/9 setup where page URLs don't have periods in them and don't end in /.
Congratulations! You've successfully installed and configured the module. Drupal will add a Cache Control header which will enable Peakhour to automatically start caching full pages. When content is changed Drupal will issue a flush request(s) with the list of tags that have changed. You can view the flush requests under your Peakhour account. Log in, administer your domain, then click on the 'Flush Logs' left menu item. secure as it can be!
As always if you need help then Contact Us and we'll gladly assist.