diff --git a/README.md b/README.md
index 8310cf251f10fc2c74eb167915369ae85f602a89..c04d4f693a9a6c47464368a2e7c82f0f247054fe 100644
--- a/README.md
+++ b/README.md
@@ -206,9 +206,10 @@ sudo a2enmod rewrite
 sudo systemctl restart apache2
 ```
 
-For the symbols cache to work we need to make sure the webserver has write access to our htdocs/public/symbols directory (the following permission may be a little bit too generous...)
+For the symbols and heatmap caches to work we need to make sure the webserver has write access (the following permission may be a little bit too generous...)
 ```
 chmod 777 ~/trackdirect/htdocs/public/symbols
+chmod 777 ~/trackdirect/htdocs/public/heatmaps
 ```
 
 If you have enabled a firewall, make sure port 80 is open.
diff --git a/htdocs/public/heatmaps/heatmap.php b/htdocs/public/heatmaps/heatmap.php
index 37db43d420c0c03fd0bed88f7824943ca4ccf1e7..7e7a5398fafd0fd2f8c58a62162a43bee1631825 100755
--- a/htdocs/public/heatmaps/heatmap.php
+++ b/htdocs/public/heatmaps/heatmap.php
@@ -77,7 +77,10 @@ $config = array(
 );
 
 $heatmap = new gd_heatmap($data, $config);
-//$heatmap->output();
 
-$heatmap->output($filename);
-readfile($filename);
+if (is_writable(dirname($filename))) {
+    $heatmap->output($filename);
+    readfile($filename);
+} else {
+    $heatmap->output();
+}