diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp
index e2e50c775df05a5d865a371bb2cead7408b307c6..efe5e7092c4e0e6068c46ae168d43fe5364e42b8 100644
--- a/indra/llfilesystem/lldiskcache.cpp
+++ b/indra/llfilesystem/lldiskcache.cpp
@@ -215,7 +215,7 @@ const std::string LLDiskCache::getCacheInfo()
     return cache_info.str();
 }
 
-void LLDiskCache::clearCache(const std::string cache_dir)
+void LLDiskCache::clearCache()
 {
     /**
      * See notes on performance in dirFileSize(..) - there may be
@@ -223,9 +223,9 @@ void LLDiskCache::clearCache(const std::string cache_dir)
      * the component files but it's called infrequently so it's
      * likely just fine
      */
-    if (boost::filesystem::is_directory(cache_dir))
+    if (boost::filesystem::is_directory(mCacheDir))
     {
-        for (auto& entry : boost::make_iterator_range(boost::filesystem::directory_iterator(cache_dir), {}))
+        for (auto& entry : boost::make_iterator_range(boost::filesystem::directory_iterator(mCacheDir), {}))
         {
             if (boost::filesystem::is_regular_file(entry))
             {
diff --git a/indra/llfilesystem/lldiskcache.h b/indra/llfilesystem/lldiskcache.h
index f718b7a328084c8b9e4b9a7ce70bd250f26e7bf3..b25eac853870cfc00c109490309e0c4f204385b2 100644
--- a/indra/llfilesystem/lldiskcache.h
+++ b/indra/llfilesystem/lldiskcache.h
@@ -126,7 +126,7 @@ class LLDiskCache :
          * directory individually. Only the files that contain a prefix defined
          * by mCacheFilenamePrefix will be removed.
          */
-        void clearCache(const std::string cache_dir);
+        void clearCache();
 
         /**
          * Return some information about the cache for use in About Box etc.
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index afafedf2076fe5e808e15bc6af076026a18586cc..9e508600642df7e6a215923f93df3b1df6805965 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -4061,6 +4061,13 @@ bool LLAppViewer::initCache()
 	LLAppViewer::getTextureCache()->setReadOnly(read_only) ;
 	LLVOCache::initParamSingleton(read_only);
 
+	// initialize the new disk cache using saved settings
+	const std::string cache_dir_name = gSavedSettings.getString("DiskCacheDirName");
+	const unsigned int cache_max_bytes = gSavedSettings.getU32("DiskCacheMaxSizeMB") * 1024 * 1024;
+	const bool enable_cache_debug_info = gSavedSettings.getBOOL("EnableDiskCacheDebugInfo");
+	const std::string cache_dir = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, cache_dir_name);
+	LLDiskCache::initParamSingleton(cache_dir, cache_max_bytes, enable_cache_debug_info);
+
 	bool texture_cache_mismatch = false;
 	if (gSavedSettings.getS32("LocalCacheVersion") != LLAppViewer::getTextureCacheVersion())
 	{
@@ -4107,13 +4114,21 @@ bool LLAppViewer::initCache()
 		gSavedSettings.setString("CacheLocationTopFolder", "");
 	}
 
-	if (mPurgeCache && !read_only)
+	if (!read_only)
 	{
-		LLSplashScreen::update(LLTrans::getString("StartupClearingCache"));
-		purgeCache();
+		if (mPurgeCache)
+		{
+			LLSplashScreen::update(LLTrans::getString("StartupClearingCache"));
+			purgeCache();
 
-        // purge the new C++ file system based cache
-        LLDiskCache::getInstance()->purge();
+			// clear the new C++ file system based cache
+			LLDiskCache::getInstance()->clearCache();
+		}
+		else
+		{
+			// purge excessive files from the new file system based cache
+			LLDiskCache::getInstance()->purge();
+		}
 	}
 
 	LLSplashScreen::update(LLTrans::getString("StartupInitializingTextureCache"));
@@ -4134,13 +4149,6 @@ bool LLAppViewer::initCache()
 
 	LLVOCache::getInstance()->initCache(LL_PATH_CACHE, gSavedSettings.getU32("CacheNumberOfRegionsForObjects"), getObjectCacheVersion());
 
-    // initialize the new disk cache using saved settings
-    const std::string cache_dir_name = gSavedSettings.getString("DiskCacheDirName");
-    const unsigned int cache_max_bytes = gSavedSettings.getU32("DiskCacheMaxSizeMB") * 1024 * 1024;
-    const bool enable_cache_debug_info = gSavedSettings.getBOOL("EnableDiskCacheDebugInfo");
-    const std::string cache_dir = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, cache_dir_name);
-    LLDiskCache::initParamSingleton(cache_dir, cache_max_bytes, enable_cache_debug_info);
-
     return true;
 }