Information for: DEVELOPERS   PARTNERS

Cookies and Varnish

With the exception of cookies stripped from static assets, all Cookie headers will reach your application on a cache miss. The cookies that reach your application will not alter or invalidate Varnish® caching, however, unless they are session cookies.

If you want to alter Varnish’s caching behavior based on cookies, you can create the following types of custom logic in your application:

  • Provide a Cache-Control response header that alters Varnish caching behavior by specifying either no-cache or a different cache lifetime, such as max-age: 5s.
  • Provide a Vary response header, as described in Varying Varnish caching by cookie value.

Session cookies invalidate Varnish caching

Content containing Drupal session cookies are never cached, as they contain personalized information that should not be displayed to other users.

Important

For a list of several common Drupal modules that set Drupal session cookies (which invalidates Varnish caching), see Modules and applications incompatible with Acquia Cloud.

Passing Acquia-provided cookies

Acquia provides the following generic cookies for your use in your headers, which you may customize with any value useful to your application:

Cookie Header value
Cookie: acquia_a=blue; X-Acquia-Cookie-A: blue
Cookie: acquia_b=green; X-Acquia-Cookie-B: green
Cookie: acquia_c=red; X-Acquia-Cookie-C: red

Passing custom cookies

Cookies prefixed with acquia_extract: will be parsed by Acquia Cloud. For example, incoming content with a Cookie: acquia_extract:WEBSHOP_CART_ID=1234; header will be parsed into the following headers:

  • Cookie: WEBSHOP_CART_ID=1234
  • X-Acquia-Cookie-Key: WEBSHOP_CART_ID
  • X-Acquia-Cookie-Value: 1234

You can configure your application to provide a Cache-Control: no-cache response header for all requests where the value of X-Acquia-Cookie-Key is WEBSHOP_CART_ID.