Skip to content
Snippets Groups Projects

Page Cache Policy Example Module

THIS MODULE IS AN EXAMPLE.

IT HAS NOT BEEN SUBJECT TO A SECURITY AUDIT AND IS NOT INTENDED TO BE USED ON A PUBLIC FACING ENVIRONMENT.

Install

This example module may be installed both manually and via composer.

Manual Installation

  • Copy the enclosed files into the ./docroot/modules/custom directory.
  • Run drupal module:install vr_automation.

Via Composer

Add this repository to your composer.json file repositories array.

{
  "repositories": [
    {
      "url": "https://git.psu.edu/drupal-8-examples/custom-page-cache-policies.git",
      "type": "git"
    }
  ]
}

Require the library.

composer require psu-drupal/vr_automation

Install the module.

drupal module:install vr_automation

Usage

Use cURL to mimic a request from a normal user, noting that the X-Drupal-Cache header displays a hit after the second request.

 curl -I https://my-drupal-site.psu.edu

Use cURL to mimic a request from a testing system, noting that the X-Drupal-Cache header is omitted from the response.

 curl -I -H "VR-Secret: CacheMeNot" https://my-drupal-site.psu.edu