8

From Heroku's information page on the read-only file system

"There are two directories that are writeable: ./tmp and ./log (under your application root). If you wish to drop a file temporarily for the duration of the request, you can write to a filename like #{RAILS_ROOT}/tmp/myfile_#{Process.pid}. There is no guarantee that this file will be there on subsequent requests (although it might be), so this should not be used for any kind of permanent storage."

Does anyone know how often files are deleted from the /tmp folder in Heroku?

Mika H.
  • 4,119
  • 11
  • 44
  • 60
  • "there is no guarantee". e.g. you shouldn't be trying to gamble on how long the file will still be there. – Marc B Jun 25 '13 at 05:03
  • @MarcB Sure, I understand that. I'm just curious about the timescale (seconds/minutes/hours/days?) Maybe I need the files 30 seconds after they're put in the `/tmp` folder – Mika H. Jun 25 '13 at 05:06

1 Answers1

8

heroku never explicitely removes files from your tmp folder.
However it is not shared between instances of your application (your dynos).

This means you can assume the tmp folder to be emptied every time you deploy your application.
As you should always be able to deploy, you need, for your own sake, to architect your app with that in mind and not rely on the tmp folder to keep files longer than the user's HTTP request.

Damien MATHIEU
  • 31,924
  • 13
  • 86
  • 94