acquia_purge_varnish
Acquia Purge Varnish provides seamless Varnish cache management for Acquia Cloud Platform directly from your Drupal site. Built with modern Drupal standards and leveraging Acquia's Cloud API v2, this module enables administrators to clear Varnish caches through an intuitive web interface or comprehensive Drush commands.
Key Features
- Web UI & Drush Support – Manage cache purging via admin interface or powerful CLI commands
- Acquia Cloud API v2 – Built with the latest API version as recommended by Acquia
- Flexible Domain Purging – Clear cache for current domain only or all domains in the environment
- OAuth2 Authentication – Secure API communication using industry-standard authentication
- Environment Auto-Detection – Automatically detects and works with your current Acquia environment
- Settings.php Override – Secure credential management for production environments
- Comprehensive Logging – Optional request logging for debugging and monitoring
- Permission-Based Access – Role-based access control for cache management
Security
Security is built into every aspect of this module:
- CSRF Protection – All routes protected with Drupal's CSRF token system
- OAuth2 Authentication – Secure API authentication flow
- Guzzle HTTP Client – Uses Drupal core's secure HTTP client (more info)
- Strict Type Safety – PHP strict types throughout for runtime safety
- Credential Protection – API credentials never exposed in logs or UI (unless explicitly enabled)
- Clean Uninstall – All configuration and credentials removed on module uninstall
Drush Commands
Complete CLI integration with Drush:
drush apv-purge– Purge Varnish cache with optional domain targetingdrush apv-status– Display environment and configuration statusdrush apv-domains– List all domains (supports JSON/YAML output)drush apv-test– Test API credentials and connectivitydrush apv-config– Configure module settings via CLI
Requirements
- Drupal: 10.x or 11.x
- Platform: Acquia Cloud Platform (dev, stage, or prod environment)
- Credentials: Acquia Cloud API Key and API Secret with cache-clearing permissions
- Drush: 13.x (optional, for CLI commands)
Configuration
Option 1: Web UI
Navigate to Configuration → Acquia Purge Varnish → Settings
/admin/config/acquia-purge/settings
Option 2: Drush Commands
drush apv-config --api-key="YOUR_KEY" --api-secret="YOUR_SECRET" drush apv-config --domain=all
Option 3: Settings.php Override (Recommended for Production)
$settings['acquia_purge_varnish_credentials'] = [ 'api_key' => 'your-acquia-api-key', 'api_secret' => 'your-acquia-api-secret', 'application_name' => 'your-app-name', // Optional - auto-detects from AH_SITE_GROUP ];
When using settings.php override, form fields are automatically disabled with an override notice.
Getting API Credentials
- Log in to Acquia Cloud Platform
- Navigate to Profile → API Tokens
- Click "Create Token" and provide a descriptive label
- Copy the API Key and API Secret immediately (Secret shown only once)
- Ensure your Acquia account has permissions to clear caches
Multiple Applications Support
The module automatically detects your application name from AH_SITE_GROUP. If you have multiple Acquia applications or need to override the detection, simply enter your application name in the configuration form. Learn more about Acquia application management.
Usage Examples
Web Interface:
Navigate to Configuration → Acquia Purge Varnish → Purge varnish and click the purge button.
Drush Commands:
# Purge all domains in current environment drush apv-purge --domain=all # Purge only current domain drush apv-purge --domain=current # Check status before purging drush apv-status # Test credentials drush apv-test # List all available domains drush apv-domains --format=json
Automation (Post-Deployment Hook):
#!/bin/bash # hooks/common/post-code-deploy/purge-varnish.sh site="$1" target_env="$2" drush @$site.$target_env apv-purge --domain=all
Permissions
Grant the "Administer Acquia Purge Varnish" permission to appropriate roles at:
People → Permissions (/admin/people/permissions)
This permission controls access to configuration, manual purging, and all Drush commands.
Modern Architecture
- Drupal 11 Standards – Fully compliant with modern Drupal best practices
- Dependency Injection – Service-based architecture throughout
- Strict Type Safety – PHP 8 strict types for enhanced reliability
- Configuration Schema – Properly defined configuration structure
- Comprehensive Error Handling – Graceful handling of API failures
- PSR-4 Autoloading – Standard PHP autoloading practices
Documentation
Upgrade from Previous Versions
Upgrading is seamless with automatic migration:
- Permission machine name updated automatically via update hook
- All existing configuration preserved
- New Drush commands immediately available
- Backward compatible with existing integrations
Legal Disclaimer
This module has not been developed, maintained, or endorsed by Acquia Inc. This is an independent open-source project with no affiliation to Acquia Inc. The module integrates with the publicly available Acquia Cloud Platform API as documented at cloudapi-docs.acquia.com.
Developed & Designed By: Alaa Haddad
A Personal Thank You for Your Support
Every project you see here, including this one, reflects countless hours of work driven by my passion for making Drupal better for everyone. Your support truly makes a difference, and there are a few simple ways you can help these projects grow and reach others who might benefit:
- Use & Share Feedback: Have you found this project (or any of my other work) helpful? Let me know what worked well or how it could be improved. Real user input drives better tools for the entire community.
- Click "Like" on Drupal.org: It may seem small, but liking this project on Drupal.org helps others discover and trust these tools.
- Spread the Word: Share these projects on social media, Slack groups, or anywhere Drupal folks connect. Your word of mouth helps these tools find the people who need them.
- Explore More of My Work: Check out my other projects on Drupal.org to see what else might support your workflow or inspire your next build.
W3CSS Theme (d8w3css) - Solo - W3CSS Paragraphs - Paragraphs Bundles - Amun - Amunet - Anhur - Acquia Purge Varnish - Cloudflare Purge - Reference Blocked Users - Solo Copy Blocks - Solo Utilities - PB Import - VVJA - Accordion - VVJC - 3D Carousel - VVJB - Basic Carousel - VVJF - 3D FlipBox - VVJH - Hero - VVJL - Lightbox - VVJP - Parallax - VVJR - Reveal - VVJS - Slideshow - VVJT - Tabs - Module Matrix - Selectify - Utilikit
If you have any questions, ideas, or feedback about my Drupal.org projects, I’d love to hear from you! To keep things open and helpful for the entire community, I encourage you to post directly in the project's issue queue on Drupal.org. This way, your questions and the answers can benefit others who may have the same needs.
At the end of the day, my goal is to make Drupal easier and more enjoyable for everyone, especially small businesses and site builders who want to create professional sites without extra hassle. Together, we can build something even better. Thank you for your support, and for being part of this journey!