Does Nexmo cache pre-recorded audio files?


  • Does Nexmo cache static audio files for customers?
  • How can I avoid Nexmo making GET requests to my server for each API call including a pre-recorded audio file reference?


You can leverage the standard HTTP Cache-Control header so that we will cache static content on our servers to allow you to limit load on your web servers.

The HTTP 1.1  Cache-Control header is used to control the behaviour of caches. The most useful parameter in this context is the max-age directive, which is used to specify (in seconds) the maximum age of the content before the cache becomes stale.

As an example, if you anticipate that your content will not change for 2 days, you could add the following HTTP Cache-Control header parameter to your server’s response:

Cache-Control: max-age=172800
The above specification notifies our voice servers to continue to use the cached version of the file until 172800 seconds (48 hours) have elapsed.


If you’ve changed a file in some way and therefore don’t want Nexmo to continue honouring the pre-existing cache directives, rather than waiting until the cache expires, you would simply need to change the audio file name (or file location) on your web server.

For example, we could suppose that the audio file name in use is audio_old.wav and you have instructed Nexmo to cache the file for three days. On the 2nd day, you want to change the content and need us to access the new version. You would simply put the new version at audio_new.wav and replace all references to audio_old.wav with audio_new.wav, which will force our servers to execute the new caching instructions. 


Additional Notes:

If the response’s headers indicate no caching, Nexmo will not cache the file.
If the request is authenticated or secure, Nexmo will not cache the file.
If no validator (an ETag or Last-Modified header) is present on a response, and it doesn’t have any explicit freshness information, it will be considered uncacheable.

Have more questions? Submit a request