Drupal · 15 min read · Updated

Caching and Edge Security on Acquia: Varnish, Memcache, CDN, WAF, Domains and SSL

The caching layers on Acquia and the cookies that quietly break Acquia Varnish, then the edge in front of it: CDN options, WAF and bot rules, domains and certificates.

Acquia varnish caching CDN edge security

This is Part 5 of 10 in Drupal on Acquia: Enterprise Operations Guide, a free series for the people who run Drupal sites on Acquia Cloud Platform. The caching layers on Acquia and the cookies that quietly break Acquia Varnish, then the edge in front of it: CDN options, WAF and bot rules, domains and certificates.

Caching on Acquia: Drupal, Acquia Varnish and Memcache

Webocreation Group’s corporate site had become slow over the summer. Pages that once loaded in under a second now took three or four. The hosting graphs showed much higher load on the application than a year earlier, although traffic had grown only slightly. Acquia Support’s first question was: “What percentage of your anonymous requests are cache hits?”

Nobody knew. When Arjun checked, the answer was about 12 percent. On a healthy Drupal site with mostly anonymous visitors, it should be well above 80. A marketing personalization script, added months earlier, was setting a cookie on every page view. Varnish treated every request with that cookie as unique and sent it straight to Drupal.

Caching is the single biggest factor in Drupal performance on Acquia. This section explains the layers and how to keep them working.

Each layer that answers a request saves work for every layer behind it (diagram from the Drupal on Acquia: Enterprise Operations Guide series)
Each layer that answers a request saves work for every layer behind it.

The caching layers

A request to a Drupal site on Acquia can be answered by several layers, from the outside in:

LayerWhereWhat it cachesControlled by
Browser cacheVisitor’s browserStatic files and pages, if headers allowCache-Control headers
CDN or edgeGlobal edge network (see the CDN and edge security section)Pages and static files close to visitorsCDN configuration and headers from Drupal
VarnishAcquia load balancersFull pages for anonymous visitors, static filesCache-Control headers, cookies, purge requests
Drupal page cacheDrupalFull pages for anonymous usersDrupal configuration
Drupal dynamic page cache and render cacheDrupalParts of pages, for all users including logged-inCache metadata in code
Memcache (or database) cache backendMemcache serviceDrupal’s internal cache binssettings.php configuration

Each layer that answers a request saves work for the layers behind it. The goal is to answer as many requests as possible as far out as possible.

How Varnish decides

Varnish sits in front of every Acquia environment. For each request, it decides whether it can serve a cached copy or must pass the request to Drupal. The main rules are:

  • Anonymous requests without session cookies can be served from cache, if the response allows it.
  • Requests with a Drupal session cookie, meaning logged-in users, go to Drupal. Drupal’s own caches still help, but Varnish does not cache personalized pages.
  • Responses must allow caching. Drupal must send a Cache-Control header with a public max-age greater than zero.
  • Unknown cookies can break caching. Acquia’s Varnish configuration is designed to ignore many common analytics cookies, but cookies that are not recognized can cause requests to bypass the cache. Acquia’s documentation lists which cookies are handled and how to name custom cookies so Varnish ignores them.

Setting the maximum age

In Drupal’s performance settings, the browser and proxy cache maximum age controls the max-age in the Cache-Control header for anonymous pages. If it is set to “no caching,” Varnish and CDNs will not cache your pages at all, and every anonymous request reaches Drupal.

Set it to a sensible value for your content, often between 15 minutes and several hours, and rely on cache purging (below) to update pages quickly when content changes. Make this setting part of your configuration in Git, so it cannot be changed accidentally on production.

Cache tags and purging

A long max-age makes caching effective, but editors expect their changes to appear quickly. Drupal solves this with cache tags. Every cached page is tagged with the things it contains, such as node:123 or config:system.menu.main. When an editor saves node 123, Drupal invalidates everything tagged node:123.

Inside Drupal, this happens automatically. To extend it to Varnish and the CDN, you need a purge mechanism. On Acquia, the standard approach uses the Purge module with the Acquia Purge module. Together they send invalidation requests to Varnish, and to Acquia’s Platform CDN where used, whenever Drupal invalidates cache tags. If you use another CDN, a matching purger module sends invalidations to that CDN as well.

Set up purging so that:

  1. Editors’ changes appear on the live site within a minute or two.
  2. The purge queue is processed reliably, usually through Drupal cron or a dedicated queue worker, and does not grow without limit.
  3. You monitor the purge queue and diagnostics in Drupal’s purge settings.

With tag-based purging in place, you can safely set long cache lifetimes, which dramatically increases cache hit rates.

Memcache

Drupal stores its internal caches, such as render cache, discovery cache and configuration cache, in “cache bins.” By default, these live in the database. On a busy site, this puts a lot of load on the database.

Acquia provides a Memcache service, and the Drupal Memcache module lets Drupal store cache bins there instead. Configure it in settings.php, following Acquia’s documentation for your generation, and keep a few bins in the database if your configuration requires it. Memcache memory is limited, so watch for evictions in your monitoring and ask Acquia about capacity if your site is large.

Checking whether caching works

You can check caching from the outside by looking at response headers. Request a page as an anonymous user, for example with curl -I, and look for:

cache-control: max-age=3600, public
age: 1532
x-cache: HIT
x-drupal-cache: HIT
x-drupal-dynamic-cache: HIT

The exact header names vary with your CDN and Acquia configuration, but the meanings are similar:

  • Cache-Control shows whether the page is allowed to be cached and for how long.
  • Age shows how many seconds the cached copy has existed. A value above zero means it came from a cache.
  • X-Cache or a similar header shows whether Varnish or the CDN served a hit or a miss.
  • X-Drupal-Cache and X-Drupal-Dynamic-Cache show whether Drupal’s own caches were used.

Also check for Set-Cookie headers on anonymous pages. An anonymous page that sets a cookie is often a page that cannot be cached.

Common cache killers

ProblemEffectFix
Max-age set to no cachingVarnish and CDN cache nothingSet a sensible max-age and use purging
Cookies set for all visitorsRequests bypass VarnishRemove the cookie, set it only when needed, or name it so Acquia’s Varnish ignores it
Sessions started for anonymous usersVisitors treated as logged inFind the module starting sessions (often forms, messages or shopping carts)
Personalized content in the pagePages cannot be sharedLoad personalized parts with JavaScript or Drupal’s lazy builders
Query strings on every URLEach variation cached separatelyStrip tracking parameters at the CDN or ignore them in caching
Cache tags invalidated too oftenCaches cleared constantlyFind code that invalidates broad tags, such as node_list, on every request
Full cache rebuilds during the dayEvery page is a miss afterwardRebuild caches only on deployments; use targeted invalidation

Caching for logged-in users

Varnish and CDNs help anonymous visitors. Editors and logged-in users depend on Drupal’s dynamic page cache and render cache. Custom code must provide correct cache metadata (cache tags, contexts and max-age) for render arrays and blocks, or Drupal will either cache too little (slow pages) or too much (wrong content shown to the wrong user). Include cache metadata in code review checklists for custom modules.

Webocreation Group: From 12 percent to 91

Arjun worked through the cache killers one by one. The personalization cookie was renamed according to Acquia’s guidance so Varnish ignored it, and the script was changed to set it only on pages where it was used. A newsletter block that started a session for every visitor was rewritten. The maximum age was raised from 5 minutes to 6 hours, with Acquia Purge handling invalidations. Tracking parameters were stripped at the edge.

Within a week, the anonymous cache hit rate rose from 12 percent to 91 percent. Average page load time fell below one second, application load dropped by two-thirds, and the performance problem disappeared without any change to the subscription.

Template: Cache health check

CheckHowHealthy resultOur result
Anonymous cache hit rateEdge or Varnish analyticsAbove 80 percent for content sites
Max-age on anonymous pagescurl -I on key pagesPublic, max-age of at least 15 minutes
Set-Cookie on anonymous pagescurl -I on key pagesNone
Purge configuredDrupal purge settingsPurger active; queue processing
Purge queue sizeDrupal purge diagnosticsSmall and stable
Memcache in usesettings.php; monitoringConfigured; low eviction rate
Dynamic page cache workingX-Drupal-Dynamic-Cache headerHIT on repeat requests
Cache rebuildsDeployment logsOnly on deployments

Checklist

  • Measure your anonymous cache hit rate at the edge and in Varnish.
  • Set a sensible browser and proxy cache maximum age in configuration.
  • Install and configure Purge with Acquia Purge, plus a purger for your CDN if needed.
  • Remove or rename cookies that cause anonymous requests to bypass the cache.
  • Find and fix anonymous sessions.
  • Configure Memcache for Drupal cache bins following Acquia’s documentation.
  • Add cache metadata checks to code review for custom code.

Common traps

  • Max-age set to no caching. Every anonymous request then reaches Drupal.
  • Marketing scripts that set cookies. One cookie can quietly break caching for the whole site.
  • Clearing all caches to fix a problem. It hides the cause and makes the site slow for everyone.
  • No purging. Without tag-based purging, you must choose between fresh content and fast pages.
  • Missing cache metadata in custom code. It causes slow pages or, worse, wrong content for the wrong user.

CDN, edge security, domains and SSL

On a Monday morning in Arjun’s second month, the corporate site’s lead form received 4,000 submissions in two hours. Every one was spam, sent by a botnet testing stolen email addresses. The CRM filled with junk, the sales team received thousands of notifications, and the form’s spam protection, a simple honeypot field, did nothing.

The attack never needed to reach Drupal at all. A web application firewall and bot management at the edge could have blocked most of it before it touched the application. This section covers the edge: CDNs, security services, domains and SSL certificates.

Visitors reach Acquia through an edge layer that caches, filters and terminates TLS (diagram from the Drupal on Acquia: Enterprise Operations Guide series)
Visitors reach Acquia through an edge layer that caches, filters and terminates TLS.

What the edge does

The edge is the network of servers between your visitors and your Acquia environment. A good edge layer provides:

  • Content delivery: caching pages and files in locations around the world, close to visitors.
  • DDoS protection: absorbing large floods of traffic before they reach your origin.
  • Web application firewall (WAF): blocking requests that match known attack patterns, such as SQL injection and cross-site scripting.
  • Bot management: distinguishing real visitors from automated traffic and blocking or challenging bad bots.
  • Access controls: blocking or allowing traffic by IP address, country or other attributes.
  • TLS termination: handling HTTPS connections with your certificates.

Your edge options on Acquia

There are three common ways to put an edge in front of an Acquia site.

OptionWhat it isStrengthsConsiderations
Acquia Platform CDNA CDN layer offered by Acquia for eligible Cloud Platform Enterprise accounts, configured to work with Acquia’s Varnish setupSimple to enable from the Cloud Platform interface; integrated purging with Acquia PurgeWorks with custom domains only; requires suitable certificates uploaded to Cloud Platform; fewer security features than a full edge platform
Acquia EdgeAcquia’s edge offering, powered by partner networks (Cloudflare or Akamai, depending on the package), with CDN, WAF, DDoS protection and bot managementEnterprise edge security through your Acquia agreement and supportPackages and features vary; confirm what your subscription includes
Your own CDN or edge providerA provider contracted directly by your organization, configured with Acquia as the originFull control; may already be your company standard; one platform across all your sitesYou manage configuration, purging integration, certificates and support yourself

Which option is right depends on your security requirements, your existing contracts and your team’s skills. Many enterprises already have a company-wide edge provider and use it for Drupal sites too. Others prefer a single Acquia contract and support relationship.

Using your own edge provider

If you put your own CDN or edge provider in front of Acquia, a few details matter:

  • Origin: point the CDN at your Acquia environment, using the domain or address Acquia specifies, and send the correct Host header so Acquia routes traffic to the right environment.
  • Domains on Acquia: the custom domain must still be added to the Acquia environment, even though DNS points to the CDN.
  • TLS between CDN and origin: use HTTPS all the way to Acquia, with a valid certificate on the Acquia side, rather than plain HTTP behind the CDN.
  • Purging: install a Drupal purger module for your CDN, so cache tag invalidations reach the edge as well as Varnish.
  • Client IP addresses: configure Drupal’s reverse proxy settings so it sees the visitor’s real IP address, not the CDN’s. This matters for logging, flood control and security modules.
  • Origin protection: restrict direct access to the Acquia origin where possible, so attackers cannot bypass the edge by connecting to Acquia directly. Discuss the options with Acquia and your CDN provider.

WAF and security rules

A WAF is only as good as its rules. Start with the provider’s managed rule sets for common attacks, then add rules specific to your site:

  • Protect login and admin paths: rate-limit /user/login, and consider restricting /user/* and /admin/* to your company network or VPN for editors, if your editorial workflow allows it.
  • Protect forms: rate-limit form submissions and use bot challenges on high-value forms.
  • Block unused methods and paths: block request types and paths your site never uses.
  • Geographic rules: if your site serves specific regions, consider challenging traffic from regions you do not serve. Use this carefully, as it can block legitimate visitors and travelers.

Run new rules in log-only or simulate mode first, review what they would block, and then enforce them. Manage rule changes through change control (see the release management section), with the security team accountable.

Domains

Each custom domain must be added to the Acquia environment that serves it, through the Cloud Platform interface, Acquia CLI or the API. Then DNS must point the domain to the right place.

SetupDNS points to
No CDNAcquia load balancer, as shown in the Cloud Platform interface
Acquia Platform CDNThe CDN addresses or hostname Acquia specifies
Acquia Edge or your own CDNThe edge provider’s hostname or addresses

The apex domain problem. A root domain, such as example.com, cannot normally use a CNAME record. You can use an A record to fixed IP addresses, use a DNS provider that supports CNAME flattening or ALIAS records, or redirect the apex to www at the edge. Many teams choose the redirect approach, so the canonical site lives on www.

Redirects between domains are best handled at the edge or in a dedicated redirect configuration, rather than in Drupal, so they are fast and do not depend on the application.

SSL/TLS certificates

Every custom domain needs a valid certificate. Depending on your setup, certificates may be:

  • Managed by your edge provider, which issues and renews certificates for the domains it serves.
  • Managed in Cloud Platform, where you can install certificates for your environments. Depending on your generation and subscription, Cloud Platform can provision certificates automatically for some domains, or you can upload certificates you purchase, including the private key and intermediate chain.
  • Both, when you use a CDN in front of Acquia: one certificate at the edge for visitors, and one on Acquia for the connection from the CDN to the origin.

Note specific requirements in Acquia’s documentation, such as key types and sizes supported for Platform CDN.

Manage certificates carefully:

  • Record every certificate: domains covered, issuer, expiry date, where it is installed, and whether it renews automatically.
  • Prefer automatic renewal wherever possible.
  • Set reminders for manual certificates 30 and 14 days before expiry, sent to a team mailbox.
  • Keep private keys secure, in a secrets manager, never in email or Git.

Domain and certificate hygiene

Review domains and certificates quarterly:

  • Remove domains from Acquia environments where they no longer belong.
  • Confirm every domain’s DNS points where you expect.
  • Check every certificate’s expiry date.
  • Confirm non-production environments are protected and not publicly indexed.

Webocreation Group: Stopping the bots at the edge

After the spam attack, Webocreation Group moved the corporate site behind an edge service with WAF and bot management. Arjun and the security team enabled the managed rule sets in log-only mode for a week, then enforced them. They added rate limits for the lead form and login page, a bot challenge on the form, and a rule restricting /admin paths to the company VPN.

A month later, a similar attack sent 30,000 form submissions in an hour. The edge blocked or challenged over 99 percent of them. Eleven reached Drupal, where the form’s own spam protection caught them. The sales team never noticed.

Template: Domain and certificate register

DomainEnvironmentDNS targetCertificate (edge / origin)Expiry and renewalOwner
www.example.comcorporate prodEdge providerEdge-managed / AcquiaEdge automatic; origin next March, auto-renewPlatform team
example.comcorporate prodEdge (redirects to www)Edge-managedAutomaticPlatform team
careers.example.comcareers prodEdge providerEdge-managed / AcquiaEdge automatic; origin next June, manualPlatform team
stage.example.comcorporate testEdge, VPN onlyEdge-managedAutomaticPlatform team

Checklist

  • Decide which edge option fits your security needs and contracts.
  • Put every production site behind a CDN with DDoS protection and a WAF.
  • Configure purging so cache invalidations reach the edge.
  • Configure Drupal’s reverse proxy settings to see real client IP addresses.
  • Add rate limits and bot protection for login and high-value forms.
  • Decide how to handle apex domains and inter-domain redirects.
  • Build a domain and certificate register with expiry reminders.
  • Review domains and certificates every quarter.

Common traps

  • No WAF on a public site. Attacks reach Drupal that should have been stopped at the edge.
  • Origin left open. Attackers can bypass the edge by connecting to Acquia directly.
  • Forgetting the domain on Acquia. DNS alone is not enough; the domain must be added to the environment.
  • Wrong client IP addresses. Without reverse proxy settings, Drupal sees the CDN instead of visitors.
  • Manual certificates with no reminders. Expired certificates take sites offline.
Drupal on Acquia: Enterprise Operations Guide (full PDF)Every article from this series in one printable PDF.PDF · 560.0 KB
Free download: unlock it in one step

Share this page

or

Mailchimp opens in a new tab to confirm. Unsubscribe any time.

Filed underDrupal
Rupak Nepali
Written byRupak Nepali

Rupak Nepali is a web developer, manage Webocreation website and the author of six books:
Getting Started with OpenCart Module Development (Packt, 2013),
OpenCart Theme and Module Development (Packt, 2015),
OpenCart 4: Dev Guide for Themes & Extensions (2024),
OpenCart 4: User Manual (2025),
Cloudflare for the Enterprise Website (2026) and
The Technical Web Guide for Marketers (2026).
Rupak has built OpenCart stores and extensions since 2010, has published more than 600 tutorials on Webocreation, and shares free OpenCart extensions on GitHub.
Find Rupak on
GitHub | Amazon | LinkedIn | X | YouTube.

Leave a Reply

Your email address will not be published. Required fields are marked *