diff --git a/config/config.sample.php b/config/config.sample.php
index 590aba714eb516180d1377cab515fa2a94e99624..0a81543589bdc216b88d76c4f5cf856b726d7ff5 100755
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -297,6 +297,9 @@ $CONFIG = array(
  * 1 -> check each file or folder at most once per request, recomended for general use if outside changes might happen
  * 2 -> check every time the filesystem is used, causes a performance hit when using external storages, not recomended for regular use
  */
-'filesystem_check_changes' => 1
+'filesystem_check_changes' => 1,
+
+/* If true, prevent owncloud from changing the cache due to changes in the filesystem for all storage */
+'filesystem_cache_readonly' => false,
 
 );
diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php
index 61b22ea75a0b072f9a64ed919ed6922a946e369d..b97070fcdf0b910e514cffba8192b2b41e6a7cb7 100644
--- a/lib/private/files/cache/scanner.php
+++ b/lib/private/files/cache/scanner.php
@@ -10,6 +10,7 @@ namespace OC\Files\Cache;
 
 use OC\Files\Filesystem;
 use OC\Hooks\BasicEmitter;
+use OCP\Config;
 
 /**
  * Class Scanner
@@ -43,6 +44,11 @@ class Scanner extends BasicEmitter {
 	 */
 	protected $permissionsCache;
 
+	/**
+	 * @var boolean $cacheActive If true, perform cache operations, if false, do not affect cache
+	 */
+	protected $cacheActive;
+
 	const SCAN_RECURSIVE = true;
 	const SCAN_SHALLOW = false;
 
@@ -54,6 +60,7 @@ class Scanner extends BasicEmitter {
 		$this->storageId = $this->storage->getId();
 		$this->cache = $storage->getCache();
 		$this->permissionsCache = $storage->getPermissionsCache();
+		$this->cacheActive = !Config::getSystemValue('filesystem_cache_readonly', false);
 	}
 
 	/**
@@ -137,9 +144,12 @@ class Scanner extends BasicEmitter {
 											$parent = '';
 										}
 										$parentCacheData = $this->cache->get($parent);
-										$this->cache->update($parentCacheData['fileid'], array(
-											'etag' => $this->storage->getETag($parent),
-										));
+										\OC_Hook::emit('Scanner', 'updateCache', array('file' => $file, 'data' => $data));
+										if($this->cacheActive) {
+											$this->cache->update($parentCacheData['fileid'], array(
+												'etag' => $this->storage->getETag($parent),
+											));
+										}
 									}
 								}
 							}
@@ -156,12 +166,18 @@ class Scanner extends BasicEmitter {
 					}
 				}
 				if (!empty($newData)) {
-					$data['fileid'] = $this->cache->put($file, $newData);
+					\OC_Hook::emit('Scanner', 'addToCache', array('file' => $file, 'data' => $newData));
+					if($this->cacheActive) {
+						$data['fileid'] = $this->cache->put($file, $newData);
+					}
 					$this->emit('\OC\Files\Cache\Scanner', 'postScanFile', array($file, $this->storageId));
 					\OC_Hook::emit('\OC\Files\Cache\Scanner', 'post_scan_file', array('path' => $file, 'storage' => $this->storageId));
 				}
 			} else {
-				$this->cache->remove($file);
+				\OC_Hook::emit('Scanner', 'removeFromCache', array('file' => $file));
+				if($this->cacheActive) {
+					$this->cache->remove($file);
+				}
 			}
 			return $data;
 		}
@@ -244,7 +260,10 @@ class Scanner extends BasicEmitter {
 			$removedChildren = \array_diff($existingChildren, $newChildren);
 			foreach ($removedChildren as $childName) {
 				$child = ($path) ? $path . '/' . $childName : $childName;
-				$this->cache->remove($child);
+				\OC_Hook::emit('Scanner', 'removeFromCache', array('file' => $child));
+				if($this->cacheActive) {
+					$this->cache->remove($child);
+				}
 			}
 			\OC_DB::commit();
 			if ($exceptionOccurred){
@@ -263,7 +282,11 @@ class Scanner extends BasicEmitter {
 					$size += $childSize;
 				}
 			}
-			$this->cache->put($path, array('size' => $size));
+			$newData = array('size' => $size);
+			\OC_Hook::emit('Scanner', 'addToCache', array('file' => $child, 'data' => $newData));
+			if($this->cacheActive) {
+				$this->cache->put($path, $newData);
+			}
 		}
 		$this->emit('\OC\Files\Cache\Scanner', 'postScanFolder', array($path, $this->storageId));
 		return $size;
@@ -290,8 +313,19 @@ class Scanner extends BasicEmitter {
 		$lastPath = null;
 		while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) {
 			$this->scan($path, self::SCAN_RECURSIVE, self::REUSE_ETAG);
-			$this->cache->correctFolderSize($path);
+			\OC_Hook::emit('Scanner', 'correctFolderSize', array('path' => $path));
+			if($this->cacheActive) {
+				$this->cache->correctFolderSize($path);
+			}
 			$lastPath = $path;
 		}
 	}
+
+	/**
+	 * Set whether the cache is affected by scan operations
+	 * @param boolean $active The active state of the cache
+	 */
+	public function setCacheActive($active) {
+		$this->cacheActive = $active;
+	}
 }