Deep-dive on the Next Gen Platform. Join the Webinar!

Skip Navigation
Show nav
Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
    • .NET
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log inorSign up
Hide categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Developer Tools
    • Command Line
    • Heroku VS Code Extension
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery & Integration (Heroku Flow)
    • Continuous Integration
  • Language Support
    • Node.js
      • Working with Node.js
      • Troubleshooting Node.js Apps
      • Node.js Behavior in Heroku
    • Ruby
      • Rails Support
      • Working with Bundler
      • Working with Ruby
      • Ruby Behavior in Heroku
      • Troubleshooting Ruby Apps
    • Python
      • Working with Python
      • Background Jobs in Python
      • Python Behavior in Heroku
      • Working with Django
    • Java
      • Java Behavior in Heroku
      • Working with Java
      • Working with Maven
      • Working with Spring Boot
      • Troubleshooting Java Apps
    • PHP
      • PHP Behavior in Heroku
      • Working with PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
    • .NET
      • Working with .NET
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
      • Migrating to Heroku Postgres
    • Heroku Key-Value Store
    • Apache Kafka on Heroku
    • Other Data Stores
  • AI
    • Working with AI
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
      • Single Sign-on (SSO)
    • Private Spaces
      • Infrastructure Networking
    • Compliance
  • Heroku Enterprise
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
  • Continuous Delivery & Integration (Heroku Flow)
  • Flushing a MemCachier Cache on Deployment

This article was contributed by The MemCachier Add-on

MemCachier manages and scales clusters of memcache servers so you can focus on your app. Tell us how much memory you need and get started for free instantly. Add capacity later as you need it.

follow @MemCachier on Twitter

Flushing a MemCachier Cache on Deployment

English — 日本語に切り替える

Last updated June 05, 2023

Table of Contents

  • Step 1: Obtain your MemCachier credentials
  • Step 2: Test out flushing the cache
  • Step 3: Subscribe to Webhook notifications
  • Additional resources

The MemCachier add-on provides an HTTP API endpoint for flushing the contents of a cache. The flush endpoint allows you to set up a Heroku App Webhook that flushes your cache every time you deploy, ensuring that your cache is clean after each deployment.

Step 1: Obtain your MemCachier credentials

To communicate with the MemCachier API, you need your MemCachier username, password, and cache ID. You can find your credentials and cache ID on the Settings page of your analytics dashboard.

Only credentials that have the API capability can access the MemCachier API. You can also manage capabilities from the analytics dashboard Settings page.

To access your application’s MemCachier analytics dashboard, run the following Heroku CLI command in your terminal:

$ heroku addons:open memcachier

Step 2: Test out flushing the cache

To test flushing your cache, you’ll perform a cURL request. You’ll pass a basic Authorization header to authenticate the request. The Authorization header requires a Base64-encoded value: a username and password separated by a colon. For example, username:password would be Base64-encoded to dXNlcm5hbWU6cGFzc3dvcmQ=.

On Unix-like operating systems such as macOS and Linux, you can Base64 encode your username and password with the following command, adding your actual username and password values:

$ echo -n <username>:<password> | base64

echo -n removes the trailing newline character. If a newline character is accidentally added when encoding, authorization will fail with the error, code=401, message=Bad user.

You can now flush your cache with the following cURL request. Make sure to substitute your cache ID and Base64-encoded credentials:

$ curl -X POST https://analytics.memcachier.com/api/v2/caches/<cache_id>/flush \
  -H 'Authorization: Basic <base64_encoded_username:password>'

Step 3: Subscribe to Webhook notifications

After you verify the cURL flush command is working by successfully flushing your cache, you’re ready to subscribe to deploy webhook notifications.

To trigger the flush command when you deploy your app, you’ll subscribe to notifications from the api:release entity. In your terminal, run the webhooks:add Heroku CLI command. Again, make sure to substitute your cache ID and Base64-encoded credentials:

$ heroku webhooks:add \
-i api:release \
-l notify \
-u https://analytics.memcachier.com/api/v2/caches/<cache_id>/flush  \
-t 'Basic <base64_encoded_username:password>'

See the Heroku App Webhooks documentation to explain the options used in that command.

Now, any time you deploy to Heroku, your cache will automatically flush its old data.

If you ever update your MemCachier credentials, you must also update your webhook.

Additional resources

See the Webhook documentation for more information on setting up Heroku Webhooks.

To learn more about the MemCachier API, see our documentation. The MemCachier add-on provides an HTTP API endpoint for flushing the contents of a cache. The flush endpoint allows you to set up a Heroku App Webhook that flushes your cache every time you deploy, ensuring that your cache is clean and ready to go.

Keep reading

  • Continuous Delivery & Integration (Heroku Flow)

Feedback

Log in to submit feedback.

Releases Heroku ChatOps (Slack Integration)

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure
  • .NET

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Github
  • LinkedIn
  • © 2025 Salesforce, Inc. All rights reserved. Various trademarks held by their respective owners. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States
  • heroku.com
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Contact
  • Cookie Preferences
  • Your Privacy Choices