Skip to main content

Bypassing Cache with HTTP Headers

Set HTTP headers to disable caching along Pantheon's edge layer, Varnish.

Exclude Specific Pages from Caching

You can use a variety of mechanisms to determine which responses from your Drupal or WordPress site should be excluded from caching. Ultimately, these mechanisms result in setting HTTP headers that signal cacheability to Varnish and recipients of the response, like a browser.

Agency WebOps Training

Learn industry best practices for caching, how to take advantage of them on the platform, and troubleshooting common issues with help from the experts at Pantheon.

Some web developers choose to aggregate all of their caching logic in one place, often the settings.php file of Drupal or a plugin dedicated to site-specific functionality in WordPress (as shown in the examples below). Alternatively, you can spread out cache-related code so that it is closest to the elements (i.e. sidebars, footers) that cause the cacheability of the response to be limited.

Here is an example of a global way to determine a Drupal response's cacheability. Use the $conf global variable to set Cache-Control: max-age=0:

  * Set $regex_path_patterns accordingly.
  * We don't set this variable for you, so you must define it
  * yourself per your specific use case before the following conditional.
  * For example, to exclude pages in the /news/ and /about/ path from cache, set:
  *   $regex_path_patterns = array(
  *     '#^/news/?#',
  *     '#^/about/?#',
  *   );

$regex_path_patterns = array(

// Loop through the patterns.
foreach ($regex_path_patterns as $regex_path_pattern) {
  if (preg_match($regex_path_pattern, $_SERVER['REQUEST_URI'])) {
    $conf['page_cache_maximum_age'] = 0;

    // No need to continue the loop once there's a match.

As an alternative to using HTTP headers to control downstream caching, you can set a NO_CACHE cookie. For details, see Working with Cookies on Pantheon.


Pantheon does not support manually editing and updating the VCL on Global CDN. We use a standard VCL for all sites on the platform. Requests are accepted, but we do not guarantee change requests will be implemented. To submit a request for Global CDN, open a Support Ticket.

Note some customizations to VCL are available via Advanced Global CDN. For more information, Contact Sales.

Test Pages Excluded from Cache

To test whether or not a page is being served from Pantheon's edge caching layer, examine the headers output (Age, Cache-Control, Set-Cookie) via the following curl command:

curl -I
HTTP/1.1 200 OK
X-Pantheon-Styx-Hostname: styx1a
server: nginx/1.0.15
content-type: text/html; charset=utf-8
x-drupal-cache: MISS
set-cookie: SESSf60876d132c0913e5fc728eec7f71e38=M1Sr0bxLbbgYmbg1EW7N8sGF4anrKP1np25EkYta-ZU; expires=Wed, 19-Dec-2012 22:04:58 GMT; path=/;; HttpOnlyCache-Control: no-cache, must-revalidate, max-age=0last-modified: Mon, 26 Nov 2012 18:31:30 +0000
expires: Sun, 19 Nov 1978 05:00:00 GMT
x-pantheon-endpoint: c18646dd-aa2b-4faa-a4e3-d71ec3a5ce43
Date: Mon, 26 Nov 2012 18:31:38 GMT
X-Varnish: 486741958
Age: 0Via: 1.1 varnish
Connection: keep-alive
Vary: Accept-Encoding, Cookie

The Cache-Control header in this example instructs Pantheon's edge caching layer (Varnish) not to cache the response for this request. If you run the command again, you should continue to see Age: 0 for excluded pages. For more details, see Testing Global CDN Caching.

More Resources