快取多個報表 (SSRS)Caching Reports (SSRS)

報表伺服器可以快取已處理報表的副本,並在使用者開啟報表時還原該副本。A report server can cache a copy of a processed report and return that copy when a user opens the report. 對使用者而言,能夠指出報表是快取副本的唯一證據是報表執行的日期和時間。To a user, the only evidence available to indicate the report is a cached copy is the date and time that the report ran. 如果日期或時間不是目前的日期和時間,且報表不是快照集,則報表是從快取擷取而來。If the date or time is not current and the report is not a snapshot, the report was retrieved from cache.

如果報表很大或存取頻繁,快取就可以縮短擷取報表所需的時間。Caching can shorten the time required to retrieve a report if the report is large or accessed frequently. 如果伺服器重新開機,所有快取的執行個體都會在報表伺服器 Web 服務再次上線時恢復。If the server is rebooted, all cached instances are reinstated when the Report Server Web service comes back online.

快取是一種效能增強技術。Caching is a performance-enhancement technique. 快取的內容為動態,而且會隨報表加入、取代或移除而變更。The contents of the cache are volatile and can change as reports are added, replaced, or removed. 如果您需要更可預測的快取策略,就應該建立報表快照集。If you require a more predictable caching strategy, you should create a report snapshot. 如需詳細資訊,請參閱 設定報表處理屬性For more information, see Set Report Processing Properties.

注意

Reporting ServicesReporting Services 會將暫存檔儲存在資料庫中,以便支援使用者工作階段和報表處理。stores temporary files in a database to support user sessions and report processing. 這些檔案會快取供內部使用,以及在單一瀏覽器工作階段期間支援一致的檢視體驗。These files are cached for internal use and to support a consistent viewing experience during a single browser session. 如需如何快取內部使用暫存檔的詳細資訊,請參閱報表伺服器資料庫 (SSRS 原生模式)For more information about how internal-use temporary files are cached, see Report Server Database (SSRS Native Mode).

快取執行個體Cached Instances

報表的快取執行個體是以報表的中繼格式為基礎。A cached instance of a report is based on the intermediate format of a report. 報表伺服器一般會以報表名稱為基礎,快取一個報表的執行個體。The report server generally caches one instance of a report based on the report name. 不過,如果報表依據查詢參數而包含不同的資料,則在任何給定時間可能會快取多種版本的報表。However, if a report can contain different data based on query parameters, multiple versions of the report may be cached at any given time. 例如,假設您有一個將區域代碼當成參數值的參數化報表。For example, suppose you have a parameterized report that takes a region code as a parameter value. 如果 4 個不同的使用者指定了 4 個唯一的區域代碼,就會建立 4 個快取副本。If four different users specify four unique region codes, four cached copies are created.

第一個以唯一的區域代碼執行報表的使用者,會建立一個包含該區域資料的快取報表。The first user who runs the report with a unique region code creates a cached report that contains data for that region. 使用相同區域代碼要求報表的後續使用者會取得快取副本。Subsequent users who request the report using the same region code get the cached copy.

並非所有報表都可以快取。Not all reports can be cached. 如果報表包含使用者相依的資料、提示使用者輸入認證或使用 Windows 驗證,則無法快取。If a report includes user-dependent data, prompts users for credentials, or uses Windows Authentication, it cannot be cached.

重新整理快取Refreshing the Cache

如果使用者在先前的快取副本過期後選取報表,快取報表就會以較新版本取代。A cached report is replaced with a newer version when a user selects the report after the previously cached copy has expired. 設定當成快取執行個體執行的報表,會依據逾期設定,定期從快取移除。Reports that are configured to run as cached instances are removed from the cache at regular intervals based on expiration settings. 您可以設定報表以分鐘為單位的逾期或在排程的時間逾期,這由資料的直接需求決定。You can set a report's expiration in minutes or at a scheduled time, as determined by the data's immediacy requirement. 除非使用 SOAP API,否則無法直接從快取刪除報表。You cannot delete reports from the cache directly unless you use the SOAP API.

若要設定快取逾期,可以使用共用排程或報表特定排程。To configure cache expiration, you can use a shared schedule or report-specific schedule. 如果您使用共用排程而且後來暫停,則當排程無法作業時,快取不會過期。If you use a shared schedule and it is subsequently paused, the cache does not expire while the schedule is inoperative. 如果共用排程後來被刪除,則排程設定的副本會儲存為報表特定排程。If the shared schedule is subsequently deleted, a copy of the schedule settings is saved as a report-specific schedule.

如果排程過期或排程引擎在快取到期日時無法使用,則報表伺服器會執行即時報表,直到已排程的作業可以繼續為止 (方法是延長排程或啟動排程服務)。If a schedule expires or if the scheduling engine is unavailable at a cache expiration date, the report server runs a live report until scheduled operations can be resumed (by either extending the schedule or starting the scheduling service).

預先載入快取Preloading the Cache

若要提升伺服器效能,您可以預先載入快取。To improve server performance, you can preload the cache. 您可以使用兩種方式,預先載入包含參數化報表執行個體集合的快取:You can preload the cache with a collection of parameterized report instances in two ways:

  1. 建立快取重新整理計畫。Create a cache refresh plan. 當您建立重新整理計畫時,可以指定單一報表的排程,或指定共用排程。When you create a refresh plan, you can specify a schedule for a single report or specify a shared schedule.

  2. 建立使用 Null 傳遞提供者的資料驅動訂閱。Create a data-driven subscription that uses the Null Delivery Provider. 您指定 Null 傳遞提供者做為訂閱中傳遞的方法時,報表伺服器會以報表伺服器資料庫做為傳遞目的地目標,並使用名為 Null 轉譯延伸模組的特定轉譯延伸模組。When you specify the Null Delivery Provider as the method of delivery in the subscription, the report server targets the report server database as the delivery destination and uses a specialized rendering extension called the null rendering extension. 相較於其他傳遞延伸模組,Null 傳遞提供者並沒有您可以透過訂閱定義來設定的傳遞設定。In contrast with other delivery extensions, the Null Delivery Provider does not have delivery settings that you can configure through a subscription definition.

如果您要快取參數化報表的多個執行個體,其中使用不同的參數值來產生不同的報表執行個體,快取報表特別有用。Caching a report is especially useful if you want to cache multiple instances of a parameterized report where different parameter values are used to produce different report instances. 請注意,您只能在報表上指定查詢式參數。Note that you can only specify query-based parameters on the report.

當您指定排程或建立資料驅動訂閱時,必須排程報表傳遞至快取的頻率。When you specify a schedule or when you create the data-driven subscription, you schedule how often the reports are delivered to the cache. 舊副本必須已經過期,新副本才能傳遞至快取。In order for new copies to be delivered to the cache, the old copies must have expired. 因此,必須設定報表的執行屬性,以包含快取逾期設定。Therefore, the Execution properties of the report must be configured to include cache expiration settings. 逾期設定必須與您定義的訂閱排程一致。The expiration setting must be consistent with the subscription schedule that you define. 例如,您若是建立一個每晚執行的訂閱,則快取也必須在每天晚上訂閱的執行階段之前過期。For example, if you create a subscription that runs every night, the cache should also expire every night prior to the subscription's run time. 如果執行屬性未包含逾期時間,則會略過較新的傳遞。If the Execution properties do not include expiration times, newer deliveries are disregarded. 如需快取重新整理計劃的詳細資訊,請參閱 排程For more information about cache refresh plans, see Schedules. 如需設定屬性的詳細資訊,請參閱 設定報表處理屬性For more information about setting properties, see Set Report Processing Properties. 如需使用資料驅動訂閱的詳細資訊,請參閱 資料驅動訂閱For more information about using data-driven subscriptions, see Data-Driven Subscriptions.

造成快取逾期的條件Conditions That Cause Cache Expiration

快取報表會因回應下列事件而無效:已修改報表定義、已修改報表參數、資料來源認證變更,或報表執行選項變更。A cached report is invalidated in response to the following events: the report definition is modified, report parameters are modified, data source credentials change, or report execution options change. 如果您刪除儲存在快取中的報表,也會刪除快取的版本。If you delete a report that is stored in the cache, the cached version is also deleted.

如果因為任何原因造成報表無法從快取執行個體轉譯 (例如,若使用者指定的參數值與用於產生快取報表的參數值不同),則報表伺服器會重新執行報表。If a report cannot be rendered from a cached instance for any reason (for example, if the parameter values that a user specifies are different from those used to produce the cached report), the report server reruns the report.

另請參閱See Also

設定處理選項 (SharePoint 整合模式的 Reporting Services) Set Processing Options (Reporting Services in SharePoint Integrated Mode)
設定報表處理屬性 Set Report Processing Properties
Reporting Services 概念 (SSRS) Reporting Services Concepts (SSRS)
預先載入快取 (報表管理員) Preload the Cache (Report Manager)
[排程] Schedules
快取共用資料集 (SSRS) Cache Shared Datasets (SSRS)
快取重新整理選項 (報表管理員)Cache Refresh Options (Report Manager)