diff --git a/config/config.sample.php b/config/config.sample.php
index 891c2eb5fa1fe92afe0539239abb8f964379e7ac..140b75706ea59e016281a6cbb0faccd097039f06 100755
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -276,6 +276,15 @@ $CONFIG = array(
 /* all css and js files will be served by the web server statically in one js file and ons css file*/
 'asset-pipeline.enabled' => false,
 
- /* where mount.json file should be stored, defaults to data/mount.json */
- 'mount_file' => '',
+/* where mount.json file should be stored, defaults to data/mount.json */
+'mount_file' => '',
+
+/*
+ * Location of the cache folder, defaults to "data/$user/cache" where "$user" is the current user.
+ *
+ * When specified, the format will change to "$cache_path/$user" where "$cache_path" is the configured
+ * cache directory and "$user" is the user.
+ *
+ */
+'cache_path' => ''
 );
diff --git a/lib/private/cache/file.php b/lib/private/cache/file.php
index 8a6ef39f61bb8061e51184ee06916781ebe5257c..be6805a9a57aea7e95419e38382e1f498f7b1fbc 100644
--- a/lib/private/cache/file.php
+++ b/lib/private/cache/file.php
@@ -1,6 +1,7 @@
 <?php
 /**
  * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
+ * Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com>
  * This file is licensed under the Affero General Public License version 3 or
  * later.
  * See the COPYING-README file.
@@ -10,22 +11,22 @@ namespace OC\Cache;
 
 class File {
 	protected $storage;
+
+	/**
+	 * Returns the cache storage for the logged in user
+	 * @return cache storage
+	 */
 	protected function getStorage() {
 		if (isset($this->storage)) {
 			return $this->storage;
 		}
 		if(\OC_User::isLoggedIn()) {
 			\OC\Files\Filesystem::initMountPoints(\OC_User::getUser());
-			$subdir = 'cache';
-			$view = new \OC\Files\View('/' . \OC_User::getUser());
-			if(!$view->file_exists($subdir)) {
-				$view->mkdir($subdir);
-			}
-			$this->storage = new \OC\Files\View('/' . \OC_User::getUser().'/'.$subdir);
+			$this->storage = new \OC\Files\View('/' . \OC_User::getUser() . '/cache');
 			return $this->storage;
 		}else{
 			\OC_Log::write('core', 'Can\'t get cache storage, user not logged in', \OC_Log::ERROR);
-			return false;
+			throw new \OC\ForbiddenException('Can\t get cache storage, user not logged in');
 		}
 	}
 
diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php
index c31e0c381805812332bfaa6b9d5acf01a226c7fb..7e27650c5574d80bb57ac9b38d47afbe032e05ff 100644
--- a/lib/private/files/filesystem.php
+++ b/lib/private/files/filesystem.php
@@ -321,10 +321,35 @@ class Filesystem {
 			self::mount('\OC\Files\Storage\Local', array('datadir' => $root), $user);
 		}
 
+		self::mountCacheDir($user);
+
 		// Chance to mount for other storages
 		\OC_Hook::emit('OC_Filesystem', 'post_initMountPoints', array('user' => $user, 'user_dir' => $root));
 	}
 
+	/**
+	 * Mounts the cache directory
+	 * @param string $user user name
+	 */
+	private static function mountCacheDir($user) {
+		$cacheBaseDir = \OC_Config::getValue('cache_path', '');
+		if ($cacheBaseDir === '') {
+			// use local cache dir relative to the user's home
+			$subdir = 'cache';
+			$view = new \OC\Files\View('/' . $user);
+			if(!$view->file_exists($subdir)) {
+				$view->mkdir($subdir);
+			}
+		} else {
+			$cacheDir = rtrim($cacheBaseDir, '/') . '/' . $user;
+			if (!file_exists($cacheDir)) {
+				mkdir($cacheDir, 0770, true);
+			}
+			// mount external cache dir to "/$user/cache" mount point
+			self::mount('\OC\Files\Storage\Local', array('datadir' => $cacheDir), '/' . $user . '/cache');
+		}
+	}
+
 	/**
 	 * get the default filesystem view
 	 *
diff --git a/lib/private/forbiddenexception.php b/lib/private/forbiddenexception.php
new file mode 100644
index 0000000000000000000000000000000000000000..14a4cd14984cd83020061e6014c822e8f808411a
--- /dev/null
+++ b/lib/private/forbiddenexception.php
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC;
+
+/**
+ * Exception thrown whenever access to a resource has
+ * been forbidden or whenever a user isn't authenticated.
+ */
+class ForbiddenException extends \Exception {
+}
diff --git a/tests/lib/files/filesystem.php b/tests/lib/files/filesystem.php
index 90f1dfe581b12674d3169c6fa66242e54ae876ac..53f528af793db009a4b1bfc5b4ecbd543c974fde 100644
--- a/tests/lib/files/filesystem.php
+++ b/tests/lib/files/filesystem.php
@@ -226,4 +226,55 @@ class Filesystem extends \PHPUnit_Framework_TestCase {
 		$path = $arguments['path'];
 		$this->assertEquals($path, \OC\Files\Filesystem::normalizePath($path)); //the path passed to the hook should already be normalized
 	}
+
+	/**
+	 * Test that the default cache dir is part of the user's home
+	 */
+	public function testMountDefaultCacheDir() {
+		$userId = uniqid('user_');
+		$oldCachePath = \OC_Config::getValue('cache_path', '');
+		// no cache path configured
+		\OC_Config::setValue('cache_path', '');
+
+		\OC_User::createUser($userId, $userId);
+		\OC\Files\Filesystem::initMountPoints($userId);
+
+		$this->assertEquals(
+			'/' . $userId . '/',
+			\OC\Files\Filesystem::getMountPoint('/' . $userId . '/cache')
+		);
+		list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath('/' . $userId . '/cache');
+		$this->assertInstanceOf('\OC\Files\Storage\Home', $storage);
+		$this->assertEquals('cache', $internalPath);
+		\OC_User::deleteUser($userId);
+
+		\OC_Config::setValue('cache_path', $oldCachePath);
+	}
+
+	/**
+	 * Test that an external cache is mounted into
+	 * the user's home
+	 */
+	public function testMountExternalCacheDir() {
+		$userId = uniqid('user_');
+
+		$oldCachePath = \OC_Config::getValue('cache_path', '');
+		// set cache path to temp dir
+		$cachePath = \OC_Helper::tmpFolder() . '/extcache';
+		\OC_Config::setValue('cache_path', $cachePath);
+
+		\OC_User::createUser($userId, $userId);
+		\OC\Files\Filesystem::initMountPoints($userId);
+
+		$this->assertEquals(
+			'/' . $userId . '/cache/',
+			\OC\Files\Filesystem::getMountPoint('/' . $userId . '/cache')
+		);
+		list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath('/' . $userId . '/cache');
+		$this->assertInstanceOf('\OC\Files\Storage\Local', $storage);
+		$this->assertEquals('', $internalPath);
+		\OC_User::deleteUser($userId);
+
+		\OC_Config::setValue('cache_path', $oldCachePath);
+	}
 }