清除 BLOB 快取 in SharePoint ServerFlush the BLOB cache in SharePoint Server

摘要:了解如何清除 SharePoint Server 2016 與 SharePoint Server 2013 的 web 應用程式的 BLOB 快取的內容。Summary: Learn how to clear the contents of the BLOB cache for a web application in SharePoint Server 2016 and SharePoint Server 2013.

BLOB 快取會將二進位大型物件 (Blob) 儲存常用的影像、 音訊及視訊檔案,例如磁碟快取和其他用來顯示網頁的檔案。每個 SharePoint 前端伺服器會保留其本身的 BLOB 快取。當您啟用 BLOB 快取時,您會指定要包含在快取以及 BLOB 快取位置的檔案類型。要求 BLOB 檔案,第一次將檔案從資料庫複製的前端伺服器上的 BLOB 快取。該相同的檔案的前端伺服器的未來要求然後會回應來自 BLOB 快取,而不是正在服務從資料庫中儲存的檔案。這可減少網路流量及資料庫伺服器上的負載。A BLOB cache is a disk-based cache that stores binary large objects (BLOBs) such as frequently used image, audio, and video files, and other files that are used to display web pages. Each SharePoint front-end server maintains its own BLOB cache. When you enable a BLOB cache, you specify the file types to include in the cache and also the location of the BLOB cache. The first time that a BLOB file is requested, the file is copied from the database to the BLOB cache on the front-end server. Future requests to the front-end server for that same file are then served from the file that is stored in the BLOB cache, instead of being served from the database. This reduces the network traffic and the load on the database server.

如需 BLOB 快取的詳細資訊,請參閱規劃快取及 SharePoint Server 中的效能For more information about BLOB caches, see Plan for caching and performance in SharePoint Server.

清除 BLOB 快取Flush the BLOB cache

當您清除 BLOB 快取時,會清除 Web 應用程式之 BLOB 快取的內容。如果 BLOB 快取與內容不同步時,這個動作非常實用。例如,在您還原內容資料庫之後,BLOB 快取就會與內容不同步。若要更正這個情形,您必須清除 BLOB 快取。下列程序說明如何清除 Web 應用程式的 BLOB 快取。When you flush the BLOB cache, you clear the contents of the BLOB cache for a web application. This is useful if the BLOB cache becomes out of sync with the content. For example, after you restore a content database, the BLOB cache will be out of sync with the content. To correct that situation, you must flush the BLOB cache. The following procedure describes how to flush the BLOB cache for a web application.

警告

清除 Web 應用程式的 BLOB 快取會影響 Web 應用程式中的所有網站集合。Flushing the BLOB cache for a web application affects all site collections in the web application.

注意

您無法使用使用者介面清除 BLOB 快取。而您使用 Microsoft PowerShell 與 SharePoint 物件模型完成這項工作。You cannot use the user interface to flush the BLOB cache. Instead, you use Microsoft PowerShell and the SharePoint object model to complete this task.

若要清除 BLOB 快取To flush the BLOB cache

  1. 確認您具備下列成員資格:Verify that you have the following memberships:

    • SQL Server 執行個體上的 securityadmin 固定伺服器角色。securityadmin fixed server role on the SQL Server instance.

    • 所有要更新之資料庫上的 db_owner 固定資料庫角色。db_owner fixed database role on all databases that are to be updated.

    • 正在執行 PowerShell Cmdlet 之所在伺服器上的系統管理員群組。Administrators group on the server on which you are running PowerShell cmdlets.

    • 請以高於上述基本要求新增必要的成員資格。Add memberships that are required beyond the minimums above.

      系統管理員可以使用 Add-SPShellAdmin Cmdlet 授與使用 SharePoint Server Cmdlet 的權限。An administrator can use the Add-SPShellAdmin cmdlet to grant permissions to use SharePoint Server cmdlets.

      注意

      [!附註] 如果您不具備上述權限,請連絡安裝程式系統管理員或 SQL Server 系統管理員要求權限。如需 PowerShell 權限的其他資訊,請參閱<權限>與 Add-SPShellAdminIf you do not have permissions, contact your Setup administrator or SQL Server administrator to request permissions. For additional information about PowerShell permissions, see Permissions and Add-SPShellAdmin.

  2. 複製下列程式碼,並將程式碼貼到文字編輯器 (例如,記事本):Copy the following code and paste it into a text editor, such as Notepad.

    $webApp = Get-SPWebApplication "<WebApplicationURL>"
    [Microsoft.SharePoint.Publishing.PublishingCache]::FlushBlobCache($webApp)
    Write-Host "Flushed the BLOB cache for:" $webApp
    
  3. 取代_<WebApplicationURL> BLOB 快取您的 web 應用程式的 URL 要清除。Replace <WebApplicationURL>_ with the URL of the web application whose BLOB cache you want to clear.

  4. 儲存檔案,並將其命名為 FlushBLOBCache.ps1。Save the file, and name it FlushBLOBCache.ps1.

    注意

    您可以使用不同的檔案名稱,但是必須將檔案儲存為副檔名為 .ps1 的 ANSI 編碼文字檔。You can use a different file name, but you must save the file as an ANSI-encoded text file that has the file name extension .ps1.

  5. 開啟 [ SharePoint 管理命令介面]。Open SharePoint Management Shell.

  6. 變更至您儲存檔案的目錄。Change to the directory where you saved the file.

  7. 在 Microsoft PowerShell 命令提示字元處輸入下列命令。At the Microsoft PowerShell command prompt, type the following command.

    ./FlushBLOBCache.ps1
    

另請參閱See also

其他資源Other Resources

使用 Windows PowerShell 編寫指令碼Scripting with Windows PowerShell