使用 Office 365 內容傳遞網路 (CDN) 搭配 SharePoint OnlineUse the Office 365 Content Delivery Network (CDN) with SharePoint Online

您可以使用內建的 Office 365 內容傳遞網路 (CDN) 來主控靜態資產,為您的 SharePoint網頁提供更佳的效能。You can use the built-in Office 365 Content Delivery Network (CDN) to host static assets to provide better performance for your SharePoint Online pages. Office 365 CDN 透過將靜態資產快取到更靠近提出要求之瀏覽器的位置 (這有助於加速下載以及減少延遲),藉此改善效能。The Office 365 CDN improves performance by caching static assets closer to the browsers requesting them, which helps to speed up downloads and reduce latency. 此外,Office 365 CDN 使用 HTTP/2 通訊協定 ,以提升壓縮和 HTTP 流水線。Also, the Office 365 CDN uses the HTTP/2 protocol for improved compression and HTTP pipelining. Office 365 CDN 服務包含在 SharePoint Online 訂閱的一部分。The Office 365 CDN service is included as part of your SharePoint Online subscription.

注意

Office 365 CDN 只適用于世界) 雲端的 實際 執行 (中的承租人。The Office 365 CDN is only available to tenants in the Production (worldwide) cloud. 美國政府、中國和德國雲彩中的承租人目前不支援 Office 365 CDN。Tenants in the US Government, China and Germany clouds do not currently support the Office 365 CDN.

Office 365 CDN 是由可讓您在多個位置或_來源_主控靜態資產的多個 CDN 組成,並透過全球高速網路提供資產。The Office 365 CDN is composed of multiple CDNs that allow you to host static assets in multiple locations, or origins, and serve them from global high-speed networks. 根據您要在 Office 365 CDN 中主控的內容類型而定,您可以新增公用來源、私人來源或兩者。Depending on the kind of content you want to host in the Office 365 CDN, you can add public origins, private origins or both. 請參閱 選擇是否每個來源都應該是公開或私人 的,如需公開和私人來源之間差異的詳細資訊。See Choose whether each origin should be public or private for more information on the difference between public and private origins.

Office 365 CDN 概念圖表Office 365 CDN conceptual diagram

如果您已熟悉 Cdn 的運作方式,您只需要完成少數幾個步驟即可為您的租使用者啟用 Office 365 CDN。If you are already familiar with the way that CDNs work, you only need to complete a few steps to enable the Office 365 CDN for your tenant. 本主題說明如何進行。This topic describes how. 如需如何開始主控靜態資產的詳細資訊,請參閱。Read on for information about how to get started hosting your static assets.

提示

有其他 Microsoft 主控的 Cdn 可搭配 Office 365 用來進行特殊的使用案例,但在本主題中不會討論這些,因為它們超出 Office 365 CDN 的範圍。There are other Microsoft-hosted CDNs that can be used with Office 365 for specialized usage scenarios, but are not discussed in this topic because they fall outside the scope of the Office 365 CDN. 如需詳細資訊,請參閱 其他 Microsoft cdnFor more information, see Other Microsoft CDNs.

回到 Office 365 的網路規劃和效能調整Head back to Network planning and performance tuning for Office 365.

在 SharePoint Online 中使用 Office 365 CDN 的概述Overview of working with the Office 365 CDN in SharePoint Online

若要為您的組織設定 Office 365 CDN,請遵循下列基本步驟:To set up the Office 365 CDN for your organization, you follow these basic steps:

完成安裝後,您可以依下列方式 管理 Office 365 CDNOnce you're done with setup, you can Manage the Office 365 CDN over time by:

  • 新增、更新及移除資產Adding, updating, and removing assets
  • 新增及移除來源Adding and removing origins
  • 設定 CDN 原則Configuring CDN policies
  • 如有必要,停用 CDNIf necessary, disabling the CDN

最後,請參閱 使用 cdn 資產 以瞭解從公用和私人來源存取 cdn 資產。Finally, see Using your CDN assets to learn about accessing your CDN assets from both public and private origins.

如需解決常見問題的指導,請參閱 疑難排解 Office 365 CDNSee Troubleshooting the Office 365 CDN for guidance on resolving common issues.

規劃 Office 365 CDN 的部署Plan for deployment of the Office 365 CDN

在您部署 Office 365 租使用者的 Office 365 CDN 之前,您應該考慮下列因素作為規劃程式的一部分。Before you deploy the Office 365 CDN for your Office 365 tenant, you should consider the following factors as part of your planning process.

決定要在 CDN 上裝載的靜態資產Determine which static assets you want to host on the CDN

一般說來,Cdn 對於主控 _靜態資產_或不經常變更的資產會最為有效。In general, CDNs are most effective for hosting static assets, or assets that don't change very often. 合理的經驗法則是找出符合部分或所有條件的檔案:A good rule of thumb is to identify files that meet some or all of these conditions:

  • 內嵌在頁面中的靜態檔案 (像是腳本和影像) 可能會對頁面載入時間產生重大的增量影響Static files embedded in a page (like scripts and images) that may have a significant incremental impact on page load times
  • 類似可執行檔和安裝檔案的大型檔案Large files like executables and installation files
  • 支援用戶端程式代碼的資源庫Resource libraries that support client-side code

例如,重複要求的小型檔案(如網站影像和腳本)可大幅改善網站轉譯效能,並在您將 SharePoint 線上網站新增至 CDN 來源時,以增量方式減少其負載。For example, small files that are repeatedly requested like site images and scripts can significantly improve site rendering performance and incrementally reduce the load on your SharePoint Online sites when you add them to a CDN origin. 您可以從 CDN 下載較大的檔案,例如安裝可執行檔,在 SharePoint Online 網站上的負載會帶來積極效能的影響,而且後續的負載也會降低,即使不經常存取。Larger files such as installation executables can be downloaded from the CDN, delivering a positive performance impact and subsequent reduction of the load on your SharePoint Online site, even if they are not accessed as often.

每個檔案的效能提升都取決於許多因素,包括用戶端接近最接近的 CDN 端點、本機網路上的暫時性情況等等。Performance improvement on a per-file basis is dependent on many factors, including the client's proximity to the nearest CDN endpoint, transient conditions on the local network, and so forth. 許多靜態檔案都很小,而且可以從 Office 365 下載(不只是一秒鐘)。Many static files are quite small, and can be downloaded from Office 365 in less than a second. 不過,網頁上可能會包含許多內嵌檔案,且累計下載時間為數秒。However, a web page may contain many embedded files with a cumulative download time of several seconds. 從 CDN 服務這些檔案可大幅減少整體頁面載入時間。Serving these files from the CDN can significantly reduce the overall page load time. 請參閱 CDN 可提供什麼效能提升? 如需範例。See What performance gains does a CDN provide? for an example.

決定您要儲存資產的位置Determine where you want to store your assets

CDN 會從一個稱為 _來源_的位置提取您的資產。The CDN fetches your assets from a location called an origin. 來源可以是可透過 URL 存取的 SharePoint 網站、文件庫或資料夾。An origin can be a SharePoint site, document library or folder that is accessible by a URL. 當您為組織指定來源時,具有極大的彈性。You have great flexibility when you specify origins for your organization. 例如,您可以指定多個來源或單一原始位置,以放置您的所有 CDN 資產。For example, you can specify multiple origins or a single origin where you want to put all your CDN assets. 您可以選擇同時包含組織的公開來源或私人來源。You can choose to have both public or private origins for your organization. 大多陣列織會選擇實現兩者的組合。Most organizations will choose to implement a combination of the two.

您可以為您的來源(例如資料夾或文件庫)建立新的容器,並新增您要從 CDN 中提供的檔案。You can create new container for your origins such as folders or document libraries, and add files you want to make available from the CDN. 如果您有想要從 CDN 取得的特定資產集,且想要將一組 CDN 資產限制為僅限容器中的檔案,這是一種很好的方法。This is a good approach if you have a specific set of assets you want to be available from the CDN, and want to restrict the set of CDN assets to only those files in the container.

您也可以將現有的網站集合、網站、文件庫或資料夾設定為來源,使該容器中的所有合格資產都可供 CDN 使用。You can also configure an existing site collection, site, library or folder as an origin, which will make all eligible assets in the container available from the CDN. 在您將現有的容器新增為來源之前,請務必確定您已知道其內容和許可權,這樣就不會無意公開資產給匿名存取或未經授權的使用者。Before you add an existing container as an origin, it's important to make sure you are aware of its contents and permissions so you do not inadvertently expose assets to anonymous access or unauthorized users.

您可以定義 cdn 原則 ,以從 CDN 中排除來源的內容。You can define CDN policies to exclude content in your origins from the CDN. CDN 原則會透過諸如 檔案類型 和 _網站分類_等屬性,將資產公開或私人來源,套用至您在原則中指定的 CdnType (私人或公開) 中的所有來源。CDN policies exclude assets in public or private origins by attributes such as file type and site classification, and are applied to all origins of the CdnType (private or public) you specify in the policy. 例如,如果您新增包含多個子網站之網站的私人來源,您可以定義一個原則,以排除標示為 機密 的網站,這樣就不會從 CDN 為已套用該分類的網站提供內容。For example, if you add a private origin consisting of a site that contains multiple subsites, you can define a policy to exclude sites marked as Confidential so content from sites with that classification applied will not be served from the CDN. 原則會套用至您已新增至 CDN 的 所有 私人來源內容。The policy will apply to content from all private origins you have added to the CDN.

請記住,「來源」越多,CDN 服務處理要求的時間就會越大。Keep in mind that the greater the number of origins, the greater the impact on the time it takes the CDN service to process requests. 建議您盡可能限制來源數量。We recommend that you limit the number of origins as much as possible.

選擇每個原產地應該是公用還是私人Choose whether each origin should be public or private

當您識別來源時,請指定是否應該 公開私密When you identify an origin, you specify whether it should be made public or private. 公用來源存取 CDN 資產是匿名的,而私人來源的 CDN 內容則是透過動態產生的權杖來保護,以獲得較高的安全性。Access to CDN assets in public origins is anonymous, and CDN content in private origins is secured by dynamically generated tokens for greater security. 不論您選擇哪個選項,當您負責管理 CDN 本身時,Microsoft 都會執行所有繁重的動作。Regardless of which option you choose, Microsoft does all the heavy lifting for you when it comes to administration of the CDN itself. 此外,您還可以在您設定 CDN 並識別來源之後,再變更您的想法。Also, you can change your mind later, after you've set up the CDN and identified your origins.

公用和私人選項都提供類似的效能提升,但各項都有獨特的屬性和優點。Both public and private options provide similar performance gains, but each has unique attributes and advantages.

Office 365 CDN 內的公開來源可以匿名方式存取,且具有資產 URL 的任何人都可以存取主控資產。Public origins within the Office 365 CDN are accessible anonymously, and hosted assets can be accessed by anyone who has the URL to the asset. 因為對公用來源中內容的存取是匿名的,您應該只使用公用來源來快取非敏感性的一般內容,例如 javascript 檔案、指令碼、圖示和影像。Because access to content in public origins is anonymous, you should only use them to cache non-sensitive generic content such as javascript files, scripts, icons and images.

Office 365 CDN 內的私人來源可提供使用者內容的私人存取權,例如 SharePoint 線上文件庫、網站和專有影像。Private origins within the Office 365 CDN provide private access to user content such as SharePoint Online document libraries, sites and proprietary images. 存取私人來源中的內容是以動態產生的標記來保護,所以只有具有原始文件庫或儲存位置許可權的使用者可以存取私人來源中的內容。Access to content in private origins is secured by dynamically generated tokens so it can only be accessed by users with permissions to the original document library or storage location. Office 365 CDN 中的私人來源僅可用於 SharePoint 線上內容,而且您只能透過從 SharePoint Online 租使用者重新導向,存取私人來源中的資產。Private origins in the Office 365 CDN can only be used for SharePoint Online content, and you can only access assets in private origins through redirection from your SharePoint Online tenant.

您可以深入瞭解如何 使用私人來源中的資產,對私人來源中的資產進行 CDN 存取的方式。You can read more about how CDN access to assets in a private origin works in Using assets in private origins.

在公用來源中主控資產的屬性與優點Attributes and advantages of hosting assets in public origins

  • 公用來源中公開的資產可供任何人匿名存取。Assets exposed in a public origin are accessible by everyone anonymously.

    重要

    您絕對不應該放置包含使用者資訊或被視為對您的組織敏感的公用來源中的資源。You should never place resources that contain user information or are considered sensitive to your organization in a public origin.

  • 如果您移除公用來源中的資產,該資產可持續從快取的30天內可用;不過,我們會在15分鐘內使 CDN 中的資產連結無效。If you remove an asset from a public origin, the asset may continue to be available for up to 30 days from the cache; however, we will invalidate links to the asset in the CDN within 15 minutes.
  • 當您主控樣式表單 (CSS 檔案) 公用來源中,您可以使用相對路徑,並在程式碼中 URIs。When you host style sheets (CSS files) in a public origin, you can use relative paths and URIs within the code. 這表示您可以參照背景圖像的位置,以及與呼叫它之資產所在位置相關的其他物件。This means that you can reference the location of background images and other objects relative to the location of the asset that's calling it.
  • 雖然您可以硬編碼公用來源的 URL,但不建議這麼做。While you can hard code a public origin's URL, doing so is not recommended. 原因是,如果對 CDN 的存取功能變成無法使用,則 URL 不會自動解析為 SharePoint Online 中的組織,而且可能會造成中斷連結和其他錯誤。The reason for this is that if access to the CDN becomes unavailable, the URL will not automatically resolve to your organization in SharePoint Online and might result in broken links and other errors.
  • Public 來源包含的預設檔案類型為: .css,eot,.gif,.ico,jpeg,.jpg,.js,.map,.map,ttf,,woff 與 woff2。)。The default file types that are included for public origins are .css, .eot, .gif, .ico, .jpeg, .jpg, .js, .map, .png, .svg, .ttf, .woff and .woff2. 您可以指定其他檔案類型。You can specify additional file types.
  • 您可以設定原則,以排除已由您指定之網站分類所識別的資產。You can configure a policy to exclude assets that have been identified by site classifications that you specify. 例如,您可以選擇排除標記為「機密」或「限制」的所有資產,即使這些資產是允許的檔案類型,而且位於公用來源。For example, you can choose to exclude all assets that are marked as "confidential" or "restricted" even if they are an allowed file type and are located in a public origin.

主控資產私人來源的屬性與優點Attributes and advantages of hosting assets in private origins

  • 私人來源僅可用於 SharePoint 線上資產。Private origins can only be used for SharePoint Online assets.
  • 如果使用者具有存取容器的許可權,則使用者只能存取其私人來源中的資產。Users can only access the assets from a private origin if they have permissions to access the container. 禁止匿名存取這些資產。Anonymous access to these assets is prevented.
  • 私人來源中的資產必須從 SharePoint Online 租使用者參考。Assets in private origins must be referred from the SharePoint Online tenant. 對私人 CDN 資產的直接存取無法運作。Direct access to private CDN assets does not work.
  • 如果您移除私人來源中的資產,該資產可能會持續從快取的一小時內可用;不過,我們會在移除資產的15分鐘內,使 CDN 中的資源連結無效。If you remove an asset from the private origin, the asset may continue to be available for up to an hour from the cache; however, we will invalidate links to the asset in the CDN within 15 minutes of the asset's removal.
  • 私人來源包含的預設檔案類型為 .gif、.ico、.gif、.jpg、.js 和 .png。The default file types that are included for private origins are .gif, .ico, .jpeg, .jpg, .js, and .png. 您可以指定其他檔案類型。You can specify additional file types.
  • 就像公開來源一樣,您可以設定原則,以排除已透過網站分類識別的資產,即使您使用萬用字元包含資料夾或文件庫中的所有資產也是一樣。Just like with public origins, you can configure a policy to exclude assets that have been identified by site classifications that you specify even if you use wildcards to include all assets within a folder or document library.

如需有關如何使用 Office 365 CDN、一般 CDN 概念及其他 Microsoft Cdn (您可以搭配 Office 365 租使用者使用)的詳細資訊,請參閱 Content 傳遞網路For more information about why to use the Office 365 CDN, general CDN concepts, and other Microsoft CDNs you can use with your Office 365 tenant, see Content Delivery Networks.

預設 CDN 來源Default CDN origins

除非您另外指定,否則 Office 365 會在您啟用 Office 365 CDN 時,為您設定某些預設來源。Unless you specify otherwise, Office 365 sets up some default origins for you when you enable the Office 365 CDN. 如果您最初選擇不進行布建,您可以在完成安裝後新增這些來源。If you initially opt not to provision them, you can add these origins after you complete setup. 除非您瞭解略過設定預設來源的結果,並有特定原因要執行此操作,否則您應允許在啟用 CDN 時建立這些結果。Unless you understand the consequences of skipping the setup of default origins and have a specific reason for doing so, you should allow them to be created when you enable the CDN.

預設私人 CDN 來源:Default private CDN origins:

  • */userphoto.aspx*/userphoto.aspx
  • */siteassets*/siteassets

預設公用 CDN 來源:Default public CDN origins:

  • */masterpage*/masterpage
  • */style 程式庫*/style library
  • */clientsideassets*/clientsideassets

注意

clientsideassets 是預設公用來源,已新增至12月2017中的 OFFICE 365 CDN 服務。clientsideassets is a default public origin that was added to the Office 365 CDN service in December 2017. 此來源必須存在,使 CDN 中的 SharePoint 架構解決方案能夠運作。This origin must be present in order for SharePoint Framework solutions in the CDN to work. 如果您已在十二月2017之前啟用 Office 365 CDN,或在啟用 CDN 時略過設定預設來源,則可以手動新增此來源。If you enabled the Office 365 CDN prior to December 2017, or if you skipped setup of default origins when you enabled the CDN, you can manually add this origin. 如需詳細資訊,請參閱 我的用戶端網頁元件或 SharePoint 架構解決方案無法運作For more information, see My client-side web part or SharePoint Framework solution isn't working.

使用 SharePoint 線上管理命令介面來設定和設定 Office 365 CDNSet up and configure the Office 365 CDN by using the SharePoint Online Management Shell

本節中的程式需要您使用 SharePoint 線上管理命令介面,連線至 SharePoint 線上。The procedures in this section require you to use the SharePoint Online Management Shell to connect to SharePoint Online. 如需相關指示,請參閱 Connect to SharePoint Online PowerShellFor instructions, see Connect to SharePoint Online PowerShell.

完成下列步驟,以使用 SharePoint 線上管理命令介面,設定 CDN 以在 SharePoint Online 中主控您的資產。Complete these steps to set up and configure the CDN to host your assets in SharePoint Online using the SharePoint Online Management Shell.

按一下以展開Click to expand

讓您的組織使用 Office 365 CDNEnable your organization to use the Office 365 CDN

在您變更租使用者 CDN 設定之前,您應該先在 Office 365 租使用者中取得私人 CDN 設定的目前狀態。Before you make changes to the tenant CDN settings, you should retrieve the current status of the private CDN configuration in your Office 365 tenant. 使用 SharePoint Online 管理命令介面來連線至您的租使用者:Connect to your tenant using the SharePoint Online Management Shell:

Connect-SPOService -Url https://contoso-admin.sharepoint.com

現在使用 SPOTenantCdnEnabled 指令程式 ,從租使用者中取得 CDN 狀態設定:Now use the Get-SPOTenantCdnEnabled cmdlet to retrieve the CDN status settings from the tenant:

Get-SPOTenantCdnEnabled -CdnType <Public | Private>

指定之 CdnType 的 CDN 狀態會輸出至螢幕。The status of the CDN for the specified CdnType will output to the screen.

使用 SPOTenantCdnEnabled Cmdlet 可讓您的組織使用 OFFICE 365 CDN。Use the Set-SPOTenantCdnEnabled cmdlet to enable your organization to use the Office 365 CDN. 您可以讓組織同時使用公用來源、私人來源或同時使用這兩者。You can enable your organization to use public origins, private origins, or both at once. 您也可以設定 CDN,在啟用時略過預設來源的設定。You can also configure the CDN to skip the setup of default origins when you enable it. 您可以隨時依照本主題所述新增這些來源。You can always add these origins later as described in this topic.

在 Windows Powershell 中 SharePoint Online:In Windows Powershell for SharePoint Online:

Set-SPOTenantCdnEnabled -CdnType <Public | Private | Both> -Enable $true

例如,若要讓您的組織同時使用公用和私人來源,請輸入下列命令:For example, to enable your organization to use both public and private origins, type the following command:

Set-SPOTenantCdnEnabled -CdnType Both -Enable $true

若要讓您的組織同時使用公用和私人來源,但略過設定預設來源,請輸入下列命令:To enable your organization to use both public and private origins but skip setting up the default origins, type the following command:

Set-SPOTenantCdnEnabled -CdnType Both -Enable $true -NoDefaultOrigins

請參閱 預設 CDN 來源 ,以取得啟用 OFFICE 365 CDN 時預設會布建之來源的相關資訊,以及略過設定預設來源的潛在影響。See Default CDN origins for information about the origins that are provisioned by default when you enable the Office 365 CDN, and the potential impact of skipping the setup of default origins.

若要讓您的組織使用公用來源,請輸入下列命令:To enable your organization to use public origins, type the following command:

Set-SPOTenantCdnEnabled -CdnType Public -Enable $true

若要讓您的組織使用私人來源,請輸入下列命令:To enable your organization to use private origins, type the following command:

Set-SPOTenantCdnEnabled -CdnType Private -Enable $true

如需此 Cmdlet 的詳細資訊,請參閱 Set-SPOTenantCdnEnabledFor more information about this cmdlet, see Set-SPOTenantCdnEnabled.

變更要包含在 Office 365 CDN (選用) 中的檔案類型清單Change the list of file types to include in the Office 365 CDN (Optional)

提示

當您使用 SPOTenantCdnPolicy 指令程式來定義檔案類型時,會覆寫目前定義的清單。When you define file types by using the Set-SPOTenantCdnPolicy cmdlet, you overwrite the currently defined list. 如果您想要將其他檔案類型新增至清單,請先使用 Cmdlet 來找出已允許的檔案類型,並將其包含在清單中,以及新的檔案類型。If you want to add additional file types to the list, use the cmdlet first to find out what file types are already allowed and include them in the list along with your new ones.

使用 SPOTenantCdnPolicy 指令程式 ,定義可由 CDN 中的公用和私人來源主控的靜態檔案類型。Use the Set-SPOTenantCdnPolicy cmdlet to define static file types that can be hosted by public and private origins in the CDN. 根據預設,允許一般資產類型,例如 .css、.gif、.jpg 和 .js。By default, common asset types are allowed, for example .css, .gif, .jpg, and .js.

在 Windows PowerShell 中 SharePoint Online:In Windows PowerShell for SharePoint Online:

Set-SPOTenantCdnPolicy -CdnType <Public | Private> -PolicyType IncludeFileExtensions -PolicyValue "<Comma-separated list of file types >"

例如,若要讓 CDN 能夠裝載 .css 和 .png 檔案,您可以輸入下列命令:For example, to enable the CDN to host .css and .png files, you would enter the command:

Set-SPOTenantCdnPolicy -CdnType Private -PolicyType IncludeFileExtensions -PolicyValue "CSS,PNG"

若要查看 CDN 目前允許的檔案類型,請使用 SPOTenantCdnPolicies Cmdlet:To see what file types are currently allowed by the CDN, use the Get-SPOTenantCdnPolicies cmdlet:

Get-SPOTenantCdnPolicies -CdnType <Public | Private>

如需這些 Cmdlet 的詳細資訊,請參閱 Set-SPOTenantCdnPolicySPOTenantCdnPoliciesFor more information about these cmdlets, see Set-SPOTenantCdnPolicy and Get-SPOTenantCdnPolicies.

變更您想要從 Office 365 CDN 中排除的網站分類清單 (選用) Change the list of site classifications you want to exclude from the Office 365 CDN (Optional)

提示

當您使用 SPOTenantCdnPolicy 指令程式排除網站分類時,會覆寫目前定義的清單。When you exclude site classifications by using the Set-SPOTenantCdnPolicy cmdlet, you overwrite the currently defined list. 如果您想要排除其他網站分類,請先使用 Cmdlet 來找出已排除的分類,然後將其新增至新的分類。If you want to exclude additional site classifications, use the cmdlet first to find out what classifications are already excluded and then add them along with your new ones.

使用 SPOTenantCdnPolicy 指令程式 來排除您不想透過 CDN 使用的網站分類。Use the Set-SPOTenantCdnPolicy cmdlet to exclude site classifications that you do not want to make available over the CDN. 根據預設,不會排除任何網站分類。By default, no site classifications are excluded.

在 Windows PowerShell 中 SharePoint Online:In Windows PowerShell for SharePoint Online:

Set-SPOTenantCdnPolicy -CdnType <Public | Private> -PolicyType ExcludeRestrictedSiteClassifications  -PolicyValue "<Comma-separated list of site classifications >"

若要查看目前限制的網站分類,請使用 SPOTenantCdnPolicies Cmdlet:To see what site classifications are currently restricted, use the Get-SPOTenantCdnPolicies cmdlet:

Get-SPOTenantCdnPolicies -CdnType <Public | Private>

將傳回的屬性為 IncludeFileExtensionsExcludeRestrictedSiteClassificationsExcludeIfNoScriptDisabledThe properties that will be returned are IncludeFileExtensions, ExcludeRestrictedSiteClassifications and ExcludeIfNoScriptDisabled.

_IncludeFileExtensions_屬性包含將從 CDN 提供服務的副檔名清單。The IncludeFileExtensions property contains the list of file extensions that will be served from the CDN.

注意

預設副檔名在 public 和 private 之間是不同的。The default file extensions are different between public and private.

_ExcludeRestrictedSiteClassifications_屬性包含您要從 CDN 中排除的網站分類。The ExcludeRestrictedSiteClassifications property contains the site classifications that you want to exclude from the CDN. 例如,您可以排除標示為 機密 的網站,以便不會從 CDN 為已套用分類的網站提供內容。For example, you can exclude sites marked as Confidential so content from sites with that classification applied will not be served from the CDN.

_ExcludeIfNoScriptDisabled_屬性會根據網站層級_NoScript_屬性設定,排除 CDN 的內容。The ExcludeIfNoScriptDisabled property excludes content from the CDN based on the site-level NoScript attribute settings. 根據預設,會將_NoScript_屬性設定為_新式_網站啟用,並針對_傳統_網站停用By default, the NoScript attribute is set to Enabled for Modern sites and Disabled for Classic sites. 這取決於您的租使用者設定。This depends on your tenant settings.

如需這些 Cmdlet 的詳細資訊,請參閱 Set-SPOTenantCdnPolicySPOTenantCdnPoliciesFor more information about these cmdlets, see Set-SPOTenantCdnPolicy and Get-SPOTenantCdnPolicies.

新增資產來源Add an origin for your assets

使用 SPOTenantCdnOrigin 指令程式 來定義原點。Use the Add-SPOTenantCdnOrigin cmdlet to define an origin. 您可以定義多個來源。You can define multiple origins. 來源是指向包含您要由 CDN 主控之資產的 SharePoint 文件庫或資料夾的 URL。The origin is a URL that points to a SharePoint library or folder that contains the assets that you want to be hosted by the CDN.

重要

您絕對不應該放置包含使用者資訊或被視為對您的組織敏感的公用來源中的資源。You should never place resources that contain user information or are considered sensitive to your organization in a public origin.

Add-SPOTenantCdnOrigin -CdnType <Public | Private> -OriginUrl <path>

_Path_的值是包含資產之文件庫或資料夾的相對路徑。The value of path is the relative path to the library or folder that contains the assets. 除了相對路徑之外,您還可以使用萬用字元。You can use wildcards in addition to relative paths. 來源支援在 URL 前面加上萬用字元。Origins support wildcards prepended to the URL. 這可讓您建立跨越多個網站的來源。This allows you to create origins that span multiple sites. 例如,若要將所有網站的所有資產都包含在 CDN 中的公用來源,請輸入下列命令:For example, to include all of the assets in the masterpages folder for all of your sites as a public origin within the CDN, type the following command:

Add-SPOTenantCdnOrigin -CdnType Public -OriginUrl */masterpage
  • 萬用字元修飾符 * / 只能在路徑的開頭使用,而且會比對指定之 url 底下的所有 URL 段。The wildcard modifier */ can only be used at the beginning of the path, and will match all URL segments under the specified URL.
  • 路徑可以指向文件庫、資料夾或網站。The path can point to a document library, folder or site. 例如,路徑 */site1 會比對網站底下的所有文件庫。For example, the path */site1 will match all the document libraries under the site.

您可以使用特定的相對路徑來新增原點。You can add an origin with a specific relative path. 您無法使用完整路徑新增原點。You cannot add an origin using the full path.

在這個範例中,會在特定網站上新增 siteassets 程式庫的私人來源:This example adds a private origin of the siteassets library on a specific site:

Add-SPOTenantCdnOrigin -CdnType Private -OriginUrl sites/site1/siteassets

在這個範例中,會在網站集合的網站資產庫中新增 folder1 資料夾的私人來源:This example adds a private origin of the folder1 folder in the site collection's site assets library:

Add-SPOTenantCdnOrigin -CdnType Private -OriginUrl sites/test/siteassets/folder1

如果路徑中有空格,您可以使用雙引號括住路徑,也可以使用 URL 編碼 %20 取代空格。If there is a space in the path, you can either surround the path in double quotes or replace the space with the URL encoding %20. 下列範例會在網站集合的 [網站資產] 文件庫中新增 資料夾 1 資料夾的私人來源:The following examples add a private origin of the folder 1 folder in the site collection's site assets library:

Add-SPOTenantCdnOrigin -CdnType Private -OriginUrl sites/test/siteassets/folder%201
Add-SPOTenantCdnOrigin -CdnType Private -OriginUrl "sites/test/siteassets/folder 1"

如需此命令及其語法的詳細資訊,請參閱 Add-SPOTenantCdnOriginFor more information about this command and its syntax, see Add-SPOTenantCdnOrigin.

注意

在 [私人來源] 中,從來源共用的資產必須先發行主要版本,然後才能從 CDN 存取。In private origins, assets being shared from an origin must have a major version published before they can be accessed from the CDN.

當您執行此命令之後,系統會同步處理整個資料中心的設定。Once you've run the command, the system synchronizes the configuration across the datacenter. 這最多可能需要15分鐘。This can take up to 15 minutes.

範例:針對線上 SharePoint 設定主版頁面和樣式庫的公開來源Example: Configure a public origin for your master pages and for your style library for SharePoint Online

一般來說,當您啟用 Office 365 CDN 時,會預設為您設定這些來源。Normally, these origins are set up for you by default when you enable the Office 365 CDN. 不過,如果您想要手動啟用它們,請遵循下列步驟。However, if you want to enable them manually, follow these steps.

  • 使用 SPOTenantCdnOrigin 指令程式 ,將樣式庫定義為公用來源。Use the Add-SPOTenantCdnOrigin cmdlet to define the style library as a public origin.
  Add-SPOTenantCdnOrigin -CdnType Public -OriginUrl */style%20library
  • 使用 SPOTenantCdnOrigin 指令程式 ,將主版頁面定義為公用來源。Use the Add-SPOTenantCdnOrigin cmdlet to define the master pages as a public origin.
  Add-SPOTenantCdnOrigin -CdnType Public -OriginUrl */masterpage

如需此命令及其語法的詳細資訊,請參閱 Add-SPOTenantCdnOriginFor more information about this command and its syntax, see Add-SPOTenantCdnOrigin.

當您執行此命令之後,系統會同步處理整個資料中心的設定。Once you've run the command, the system synchronizes the configuration across the datacenter. 這最多可能需要15分鐘。This can take up to 15 minutes.

範例:針對線上 SharePoint 設定網站資產、網站頁面及發佈影像的私人來源Example: Configure a private origin for your site assets, site pages, and publishing images for SharePoint Online

  • 使用 SPOTenantCdnOrigin 指令程式 ,將「網站資產」資料夾定義為專用來源。Use the Add-SPOTenantCdnOrigin cmdlet to define the site assets folder as a private origin.
  Add-SPOTenantCdnOrigin -CdnType Private -OriginUrl */siteassets
  • 使用 SPOTenantCdnOrigin 指令程式 ,將「網站頁面」資料夾定義為專用來源。Use the Add-SPOTenantCdnOrigin cmdlet to define the site pages folder as a private origin.
  Add-SPOTenantCdnOrigin -CdnType Private -OriginUrl */sitepages
  • 使用 SPOTenantCdnOrigin 指令程式 ,將 [發佈影像] 資料夾定義為專用來源。Use the Add-SPOTenantCdnOrigin cmdlet to define the publishing images folder as a private origin.
  Add-SPOTenantCdnOrigin -CdnType Private -OriginUrl */publishingimages

如需此命令及其語法的詳細資訊,請參閱 Add-SPOTenantCdnOriginFor more information about this command and its syntax, see Add-SPOTenantCdnOrigin.

當您執行此命令之後,系統會同步處理整個資料中心的設定。Once you've run the command, the system synchronizes the configuration across the datacenter. 這最多可能需要15分鐘。This can take up to 15 minutes.

範例:設定 SharePoint Online 之網站集合的私人來源Example: Configure a private origin for a site collection for SharePoint Online

使用 SPOTenantCdnOrigin 指令程式 ,將網站集合定義為私人來源。Use the Add-SPOTenantCdnOrigin cmdlet to define a site collection as a private origin. 例如:For example:

Add-SPOTenantCdnOrigin -CdnType Private -OriginUrl sites/site1/siteassets

如需此命令及其語法的詳細資訊,請參閱 Add-SPOTenantCdnOriginFor more information about this command and its syntax, see Add-SPOTenantCdnOrigin.

當您執行此命令之後,系統會同步處理整個資料中心的設定。Once you've run the command, the system synchronizes the configuration across the datacenter. 在連線至 CDN 服務的 SharePoint Online 租使用者時,您可能會看到預期的設定 擱置 郵件。You may see a Configuration pending message which is expected as the SharePoint Online tenant connects to the CDN service. 這最多可能需要15分鐘。This can take up to 15 minutes.

管理 Office 365 CDNManage the Office 365 CDN

在您設定 CDN 後,您可以在更新內容或需要變更時變更設定,如本節所述。Once you've set up the CDN, you can make changes to your configuration as you update content or as your needs change, as described in this section.

新增、更新或移除 Office 365 CDN 中的資產Add, update, or remove assets from the Office 365 CDN

完成設定步驟之後,您就可以新增資產,並隨時更新或移除現有的資產。Once you've completed the setup steps, you can add new assets, and update or remove existing assets whenever you want. 您只需對您識別為原產地的資料夾或 SharePoint 文件庫中的資產進行變更。Just make your changes to the assets in the folder or SharePoint library that you identified as an origin. 如果您新增資產,可立即透過 CDN 使用。If you add a new asset, it is available through the CDN immediately. 不過,如果您更新資產,最多需要15分鐘的時間,新的副本才會傳播並變得可用於 CDN。However, if you update the asset, it will take up to 15 minutes for the new copy to propagate and become available in the CDN.

如果您需要取得原始位置,您可以使用 SPOTenantCdnOrigins Cmdlet。If you need to retrieve the location of the origin, you can use the Get-SPOTenantCdnOrigins cmdlet. 如需如何使用此 Cmdlet 的詳細資訊,請參閱 SPOTenantCdnOriginsFor information on how to use this cmdlet, see Get-SPOTenantCdnOrigins.

從 Office 365 CDN 移除原產地Remove an origin from the Office 365 CDN

您可以移除您識別為原產地的資料夾或 SharePoint 程式庫的存取權。You can remove access to a folder or SharePoint library that you identified as an origin. 若要這麼做,請使用 SPOTenantCdnOrigin Cmdlet。To do this, use the Remove-SPOTenantCdnOrigin cmdlet.

Remove-SPOTenantCdnOrigin -OriginUrl <path> -CdnType <Public | Private | Both>

如需如何使用此 Cmdlet 的詳細資訊,請參閱 Remove-SPOTenantCdnOriginFor information on how to use this cmdlet, see Remove-SPOTenantCdnOrigin.

在 Office 365 CDN 中修改來源Modify an origin in the Office 365 CDN

您無法修改您已建立的來源。You cannot modify an origin you've created. 請改為移除原始位置,然後新增一個新的位置。Instead, remove the origin and then add a new one. 如需詳細資訊,請參閱 從 Office 365 CDN 移除原點新增資產來源For more information, see To remove an origin from the Office 365 CDN and To add an origin for your assets.

停用 Office 365 CDNDisable the Office 365 CDN

使用 SPOTenantCdnEnabled 指令程式 為您的組織停用 CDN。Use the Set-SPOTenantCdnEnabled cmdlet to disable the CDN for your organization. 如果您已啟用 CDN 的公開和私人來源,則需要執行 Cmdlet 兩次,如下列範例所示。If you have both the public and private origins enabled for the CDN, you need to run the cmdlet twice as shown in the following examples.

若要停用 CDN 中的公用來源,請輸入下列命令:To disable use of public origins in the CDN, enter the following command:

Set-SPOTenantCdnEnabled -CdnType Public -Enable $false

若要停用 CDN 中的私人來源,請輸入下列命令:To disable use of the private origins in the CDN, enter the following command:

Set-SPOTenantCdnEnabled -CdnType Private -Enable $false

如需此 Cmdlet 的詳細資訊,請參閱 Set-SPOTenantCdnEnabledFor more information about this cmdlet, see Set-SPOTenantCdnEnabled.

使用 PnP 來設定及設定 Office 365 CDN PowerShellSet up and configure the Office 365 CDN by using PnP PowerShell

本節中的程式需要您使用 PnP PowerShell 連線至 SharePoint 線上。The procedures in this section require you to use PnP PowerShell to connect to SharePoint Online. 如需相關指示,請參閱 PnP PowerShell 快速入門。For instructions, see Getting started with PnP PowerShell.

完成這些步驟,使用 PnP PowerShell,設定並設定 CDN,以在 SharePoint 線上中主控您的資產。Complete these steps to set up and configure the CDN to host your assets in SharePoint Online using PnP PowerShell.

按一下以展開Click to expand

讓您的組織使用 Office 365 CDNEnable your organization to use the Office 365 CDN

在您變更租使用者 CDN 設定之前,您應該先在 Office 365 租使用者中取得私人 CDN 設定的目前狀態。Before you make changes to the tenant CDN settings, you should retrieve the current status of the private CDN configuration in your Office 365 tenant. 使用 PnP 連接至您的租使用者 PowerShell:Connect to your tenant using PnP PowerShell:

Connect-PnPOnline -Url https://contoso-admin.sharepoint.com -UseWebLogin

現在使用 PnPTenantCdnEnabled 指令程式 ,從租使用者中取得 CDN 狀態設定:Now use the Get-PnPTenantCdnEnabled cmdlet to retrieve the CDN status settings from the tenant:

Get-PnPTenantCdnEnabled -CdnType <Public | Private>

指定之 CdnType 的 CDN 狀態會輸出至螢幕。The status of the CDN for the specified CdnType will output to the screen.

使用 PnPTenantCdnEnabled Cmdlet 可讓您的組織使用 OFFICE 365 CDN。Use the Set-PnPTenantCdnEnabled cmdlet to enable your organization to use the Office 365 CDN. 您可以讓組織同時使用公用來源、私人來源或兩者同時使用。You can enable your organization to use public origins, private origins, or both at at the same time. 您也可以設定 CDN,在啟用時略過預設來源的設定。You can also configure the CDN to skip the setup of default origins when you enable it. 您可以隨時依照本主題所述新增這些來源。You can always add these origins later as described in this topic.

PnP PowerShell:In PnP PowerShell:

Set-PnPTenantCdnEnabled -CdnType <Public | Private | Both> -Enable $true

例如,若要讓您的組織同時使用公用和私人來源,請輸入下列命令:For example, to enable your organization to use both public and private origins, type the following command:

Set-PnPTenantCdnEnabled -CdnType Both -Enable $true

若要讓您的組織同時使用公用和私人來源,但略過設定預設來源,請輸入下列命令:To enable your organization to use both public and private origins but skip setting up the default origins, type the following command:

Set-PnPTenantCdnEnabled -CdnType Both -Enable $true -NoDefaultOrigins

請參閱 預設 CDN 來源 ,以取得啟用 OFFICE 365 CDN 時預設會布建之來源的相關資訊,以及略過設定預設來源的潛在影響。See Default CDN origins for information about the origins that are provisioned by default when you enable the Office 365 CDN, and the potential impact of skipping the setup of default origins.

若要讓您的組織使用公用來源,請輸入下列命令:To enable your organization to use public origins, type the following command:

Set-PnPTenantCdnEnabled -CdnType Public -Enable $true

若要讓您的組織使用私人來源,請輸入下列命令:To enable your organization to use private origins, type the following command:

Set-PnPTenantCdnEnabled -CdnType Private -Enable $true

如需此 Cmdlet 的詳細資訊,請參閱 Set-PnPTenantCdnEnabledFor more information about this cmdlet, see Set-PnPTenantCdnEnabled.

變更要包含在 Office 365 CDN (選用) 中的檔案類型清單Change the list of file types to include in the Office 365 CDN (Optional)

提示

當您使用 PnPTenantCdnPolicy 指令程式來定義檔案類型時,會覆寫目前定義的清單。When you define file types by using the Set-PnPTenantCdnPolicy cmdlet, you overwrite the currently defined list. 如果您想要將其他檔案類型新增至清單,請先使用 Cmdlet 來找出已允許的檔案類型,並將其包含在清單中,以及新的檔案類型。If you want to add additional file types to the list, use the cmdlet first to find out what file types are already allowed and include them in the list along with your new ones.

使用 PnPTenantCdnPolicy 指令程式 ,定義可由 CDN 中的公用和私人來源主控的靜態檔案類型。Use the Set-PnPTenantCdnPolicy cmdlet to define static file types that can be hosted by public and private origins in the CDN. 根據預設,允許一般資產類型,例如 .css、.gif、.jpg 和 .js。By default, common asset types are allowed, for example .css, .gif, .jpg, and .js.

PnP PowerShell:In PnP PowerShell:

Set-PnPTenantCdnPolicy -CdnType <Public | Private> -PolicyType IncludeFileExtensions -PolicyValue "<Comma-separated list of file types >"

例如,若要讓 CDN 能夠裝載 .css 和 .png 檔案,您可以輸入下列命令:For example, to enable the CDN to host .css and .png files, you would enter the command:

Set-PnPTenantCdnPolicy -CdnType Private -PolicyType IncludeFileExtensions -PolicyValue "CSS,PNG"

若要查看 CDN 目前允許的檔案類型,請使用 PnPTenantCdnPolicies Cmdlet:To see what file types are currently allowed by the CDN, use the Get-PnPTenantCdnPolicies cmdlet:

Get-PnPTenantCdnPolicies -CdnType <Public | Private>

如需這些 Cmdlet 的詳細資訊,請參閱 Set-PnPTenantCdnPolicyPnPTenantCdnPoliciesFor more information about these cmdlets, see Set-PnPTenantCdnPolicy and Get-PnPTenantCdnPolicies.

變更您想要從 Office 365 CDN 中排除的網站分類清單 (選用) Change the list of site classifications you want to exclude from the Office 365 CDN (Optional)

提示

當您使用 PnPTenantCdnPolicy 指令程式排除網站分類時,會覆寫目前定義的清單。When you exclude site classifications by using the Set-PnPTenantCdnPolicy cmdlet, you overwrite the currently defined list. 如果您想要排除其他網站分類,請先使用 Cmdlet 來找出已排除的分類,然後將其新增至新的分類。If you want to exclude additional site classifications, use the cmdlet first to find out what classifications are already excluded and then add them along with your new ones.

使用 PnPTenantCdnPolicy 指令程式 來排除您不想透過 CDN 使用的網站分類。Use the Set-PnPTenantCdnPolicy cmdlet to exclude site classifications that you do not want to make available over the CDN. 根據預設,不會排除任何網站分類。By default, no site classifications are excluded.

PnP PowerShell:In PnP PowerShell:

Set-PnPTenantCdnPolicy -CdnType <Public | Private> -PolicyType ExcludeRestrictedSiteClassifications  -PolicyValue "<Comma-separated list of site classifications>"

若要查看目前限制的網站分類,請使用 PnPTenantCdnPolicies Cmdlet:To see what site classifications are currently restricted, use the Get-PnPTenantCdnPolicies cmdlet:

Get-PnPTenantCdnPolicies -CdnType <Public | Private>

將傳回的屬性為 IncludeFileExtensionsExcludeRestrictedSiteClassificationsExcludeIfNoScriptDisabledThe properties that will be returned are IncludeFileExtensions, ExcludeRestrictedSiteClassifications and ExcludeIfNoScriptDisabled.

_IncludeFileExtensions_屬性包含將從 CDN 提供服務的副檔名清單。The IncludeFileExtensions property contains the list of file extensions that will be served from the CDN.

注意

預設副檔名在 public 和 private 之間是不同的。The default file extensions are different between public and private.

_ExcludeRestrictedSiteClassifications_屬性包含您要從 CDN 中排除的網站分類。The ExcludeRestrictedSiteClassifications property contains the site classifications that you want to exclude from the CDN. 例如,您可以排除標示為 機密 的網站,以便不會從 CDN 為已套用分類的網站提供內容。For example, you can exclude sites marked as Confidential so content from sites with that classification applied will not be served from the CDN.

_ExcludeIfNoScriptDisabled_屬性會根據網站層級_NoScript_屬性設定,排除 CDN 的內容。The ExcludeIfNoScriptDisabled property excludes content from the CDN based on the site-level NoScript attribute settings. 根據預設,會將_NoScript_屬性設定為_新式_網站啟用,並針對_傳統_網站停用By default, the NoScript attribute is set to Enabled for Modern sites and Disabled for Classic sites. 這取決於您的租使用者設定。This depends on your tenant settings.

如需這些 Cmdlet 的詳細資訊,請參閱 Set-PnPTenantCdnPolicyPnPTenantCdnPoliciesFor more information about these cmdlets, see Set-PnPTenantCdnPolicy and Get-PnPTenantCdnPolicies.

新增資產來源Add an origin for your assets

使用 PnPTenantCdnOrigin 指令程式 來定義原點。Use the Add-PnPTenantCdnOrigin cmdlet to define an origin. 您可以定義多個來源。You can define multiple origins. 來源是指向包含您要由 CDN 主控之資產的 SharePoint 文件庫或資料夾的 URL。The origin is a URL that points to a SharePoint library or folder that contains the assets that you want to be hosted by the CDN.

重要

您絕對不應該放置包含使用者資訊或被視為對您的組織敏感的公用來源中的資源。You should never place resources that contain user information or are considered sensitive to your organization in a public origin.

Add-PnPTenantCdnOrigin -CdnType <Public | Private> -OriginUrl <path>

_Path_的值是包含資產之文件庫或資料夾的相對路徑。The value of path is the relative path to the library or folder that contains the assets. 除了相對路徑之外,您還可以使用萬用字元。You can use wildcards in addition to relative paths. 來源支援在 URL 前面加上萬用字元。Origins support wildcards prepended to the URL. 這可讓您建立跨越多個網站的來源。This allows you to create origins that span multiple sites. 例如,若要將所有網站的所有資產都包含在 CDN 中的公用來源,請輸入下列命令:For example, to include all of the assets in the masterpages folder for all of your sites as a public origin within the CDN, type the following command:

Add-PnPTenantCdnOrigin -CdnType Public -OriginUrl */masterpage
  • 萬用字元修飾符 * / 只能在路徑的開頭使用,而且會比對指定之 url 底下的所有 URL 段。The wildcard modifier */ can only be used at the beginning of the path, and will match all URL segments under the specified URL.
  • 路徑可以指向文件庫、資料夾或網站。The path can point to a document library, folder or site. 例如,路徑 */site1 會比對網站底下的所有文件庫。For example, the path */site1 will match all the document libraries under the site.

您可以使用特定的相對路徑來新增原點。You can add an origin with a specific relative path. 您無法使用完整路徑新增原點。You cannot add an origin using the full path.

本範例會在特定網站上新增網站資產庫的私人來源:This example adds a private origin of the site assets library on a specific site:

Add-PnPTenantCdnOrigin -CdnType Private -OriginUrl sites/site1/siteassets

在這個範例中,會在網站集合的網站資產庫中新增 folder1 資料夾的私人來源:This example adds a private origin of the folder1 folder in the site collection's site assets library:

Add-PnPTenantCdnOrigin -CdnType Private -OriginUrl sites/test/siteassets/folder1

如果路徑中有空格,您可以使用雙引號括住路徑,也可以使用 URL 編碼 %20 取代空格。If there is a space in the path, you can either surround the path in double quotes or replace the space with the URL encoding %20. 下列範例會在網站集合的 [網站資產] 文件庫中新增 資料夾 1 資料夾的私人來源:The following examples add a private origin of the folder 1 folder in the site collection's site assets library:

Add-PnPTenantCdnOrigin -CdnType Private -OriginUrl sites/test/siteassets/folder%201
Add-PnPTenantCdnOrigin -CdnType Private -OriginUrl "sites/test/siteassets/folder 1"

如需此命令及其語法的詳細資訊,請參閱 Add-PnPTenantCdnOriginFor more information about this command and its syntax, see Add-PnPTenantCdnOrigin.

注意

在 [私人來源] 中,從來源共用的資產必須先發行主要版本,然後才能從 CDN 存取。In private origins, assets being shared from an origin must have a major version published before they can be accessed from the CDN.

當您執行此命令之後,系統會同步處理整個資料中心的設定。Once you've run the command, the system synchronizes the configuration across the datacenter. 這最多可能需要15分鐘。This can take up to 15 minutes.

範例:針對線上 SharePoint 設定主版頁面和樣式庫的公開來源Example: Configure a public origin for your master pages and for your style library for SharePoint Online

一般來說,當您啟用 Office 365 CDN 時,會預設為您設定這些來源。Normally, these origins are set up for you by default when you enable the Office 365 CDN. 不過,如果您想要手動啟用它們,請遵循下列步驟。However, if you want to enable them manually, follow these steps.

  • 使用 PnPTenantCdnOrigin 指令程式 ,將樣式庫定義為公用來源。Use the Add-PnPTenantCdnOrigin cmdlet to define the style library as a public origin.
  Add-PnPTenantCdnOrigin -CdnType Public -OriginUrl */style%20library
  • 使用 PnPTenantCdnOrigin 指令程式 ,將主版頁面定義為公用來源。Use the Add-PnPTenantCdnOrigin cmdlet to define the master pages as a public origin.
  Add-PnPTenantCdnOrigin -CdnType Public -OriginUrl */masterpage

如需此命令及其語法的詳細資訊,請參閱 Add-PnPTenantCdnOriginFor more information about this command and its syntax, see Add-PnPTenantCdnOrigin.

當您執行此命令之後,系統會同步處理整個資料中心的設定。Once you've run the command, the system synchronizes the configuration across the datacenter. 這最多可能需要15分鐘。This can take up to 15 minutes.

範例:針對線上 SharePoint 設定網站資產、網站頁面及發佈影像的私人來源Example: Configure a private origin for your site assets, site pages, and publishing images for SharePoint Online

  • 使用 PnPTenantCdnOrigin 指令程式 ,將「網站資產」資料夾定義為專用來源。Use the Add-PnPTenantCdnOrigin cmdlet to define the site assets folder as a private origin.
  Add-PnPTenantCdnOrigin -CdnType Private -OriginUrl */siteassets
  • 使用 PnPTenantCdnOrigin 指令程式 ,將「網站頁面」資料夾定義為專用來源。Use the Add-PnPTenantCdnOrigin cmdlet to define the site pages folder as a private origin.
  Add-PnPTenantCdnOrigin -CdnType Private -OriginUrl */sitepages
  • 使用 PnPTenantCdnOrigin 指令程式 ,將 [發佈影像] 資料夾定義為專用來源。Use the Add-PnPTenantCdnOrigin cmdlet to define the publishing images folder as a private origin.
  Add-PnPTenantCdnOrigin -CdnType Private -OriginUrl */publishingimages

如需此命令及其語法的詳細資訊,請參閱 Add-PnPTenantCdnOriginFor more information about this command and its syntax, see Add-PnPTenantCdnOrigin.

當您執行此命令之後,系統會同步處理整個資料中心的設定。Once you've run the command, the system synchronizes the configuration across the datacenter. 這最多可能需要15分鐘。This can take up to 15 minutes.

範例:設定 SharePoint Online 之網站集合的私人來源Example: Configure a private origin for a site collection for SharePoint Online

使用 PnPTenantCdnOrigin 指令程式 ,將網站集合定義為私人來源。Use the Add-PnPTenantCdnOrigin cmdlet to define a site collection as a private origin. 例如:For example:

Add-PnPTenantCdnOrigin -CdnType Private -OriginUrl sites/site1/siteassets

如需此命令及其語法的詳細資訊,請參閱 Add-PnPTenantCdnOriginFor more information about this command and its syntax, see Add-PnPTenantCdnOrigin.

當您執行此命令之後,系統會同步處理整個資料中心的設定。Once you've run the command, the system synchronizes the configuration across the datacenter. 在連線至 CDN 服務的 SharePoint Online 租使用者時,您可能會看到預期的設定 擱置 郵件。You may see a Configuration pending message which is expected as the SharePoint Online tenant connects to the CDN service. 這最多可能需要15分鐘。This can take up to 15 minutes.

管理 Office 365 CDNManage the Office 365 CDN

在您設定 CDN 後,您可以在更新內容或需要變更時變更設定,如本節所述。Once you've set up the CDN, you can make changes to your configuration as you update content or as your needs change, as described in this section.

新增、更新或移除 Office 365 CDN 中的資產Add, update, or remove assets from the Office 365 CDN

完成設定步驟之後,您就可以新增資產,並隨時更新或移除現有的資產。Once you've completed the setup steps, you can add new assets, and update or remove existing assets whenever you want. 您只需對您識別為原產地的資料夾或 SharePoint 文件庫中的資產進行變更。Just make your changes to the assets in the folder or SharePoint library that you identified as an origin. 如果您新增資產,可立即透過 CDN 使用。If you add a new asset, it is available through the CDN immediately. 不過,如果您更新資產,最多需要15分鐘的時間,新的副本才會傳播並變得可用於 CDN。However, if you update the asset, it will take up to 15 minutes for the new copy to propagate and become available in the CDN.

如果您需要取得原始位置,您可以使用 PnPTenantCdnOrigin Cmdlet。If you need to retrieve the location of the origin, you can use the Get-PnPTenantCdnOrigin cmdlet. 如需如何使用此 Cmdlet 的詳細資訊,請參閱 PnPTenantCdnOriginFor information on how to use this cmdlet, see Get-PnPTenantCdnOrigin.

從 Office 365 CDN 移除原產地Remove an origin from the Office 365 CDN

您可以移除您識別為原產地的資料夾或 SharePoint 程式庫的存取權。You can remove access to a folder or SharePoint library that you identified as an origin. 若要這麼做,請使用 PnPTenantCdnOrigin Cmdlet。To do this, use the Remove-PnPTenantCdnOrigin cmdlet.

Remove-PnPTenantCdnOrigin -OriginUrl <path> -CdnType <Public | Private | Both>

如需如何使用此 Cmdlet 的詳細資訊,請參閱 Remove-PnPTenantCdnOriginFor information on how to use this cmdlet, see Remove-PnPTenantCdnOrigin.

在 Office 365 CDN 中修改來源Modify an origin in the Office 365 CDN

您無法修改您已建立的來源。You cannot modify an origin you've created. 請改為移除原始位置,然後新增一個新的位置。Instead, remove the origin and then add a new one. 如需詳細資訊,請參閱 從 Office 365 CDN 移除原點新增資產來源For more information, see To remove an origin from the Office 365 CDN and To add an origin for your assets.

停用 Office 365 CDNDisable the Office 365 CDN

使用 PnPTenantCdnEnabled 指令程式 為您的組織停用 CDN。Use the Set-PnPTenantCdnEnabled cmdlet to disable the CDN for your organization. 如果您已啟用 CDN 的公開和私人來源,則需要執行 Cmdlet 兩次,如下列範例所示。If you have both the public and private origins enabled for the CDN, you need to run the cmdlet twice as shown in the following examples.

若要停用 CDN 中的公用來源,請輸入下列命令:To disable use of public origins in the CDN, enter the following command:

Set-PnPTenantCdnEnabled -CdnType Public -Enable $false

若要停用 CDN 中的私人來源,請輸入下列命令:To disable use of the private origins in the CDN, enter the following command:

Set-PnPTenantCdnEnabled -CdnType Private -Enable $false

如需此 Cmdlet 的詳細資訊,請參閱 Set-PnPTenantCdnEnabledFor more information about this cmdlet, see Set-PnPTenantCdnEnabled.

使用 Office 365 CLI 安裝和設定 Office 365 CDNSet up and configure the Office 365 CDN using the Office 365 CLI

本節中的程式需要您已安裝 Office 365 CLIThe procedures in this section require that you have installed the Office 365 CLI. 接下來,使用 入命令連線到您的 Office 365 租使用者。Next, connect to your Office 365 tenant using the login command.

完成這些步驟,使用 Office 365 CLI,設定並設定 CDN,以在 SharePoint Online 中主控您的資產。Complete these steps to set up and configure the CDN to host your assets in SharePoint Online using the Office 365 CLI.

按一下以展開Click to expand

啟用 Office 365 CDNEnable the Office 365 CDN

您可以使用 spo CDN 組 命令,在租使用者中管理 OFFICE 365 CDN 的狀態。You can manage the state of the Office 365 CDN in your tenant using the spo cdn set command.

若要在租使用者中啟用 Office 365 公用 CDN,請執行下列作業:To enable the Office 365 Public CDN in your tenant execute:

spo cdn set --type Public --enabled true

若要啟用 Office 365 SharePoint CDN,請執行:To enable the Office 365 SharePoint CDN, execute:

spo cdn set --type Private --enabled true

查看 Office 365 CDN 的目前狀態View the current status of the Office 365 CDN

若要檢查是否已啟用或停用特定類型的 Office 365 CDN,請使用 spo CDN get 命令。To check if the particular type of Office 365 CDN is enabled or disabled, use the spo cdn get command.

若要檢查是否已啟用 Office 365 公用 CDN,請執行:To check if the Office 365 Public CDN is enabled, execute:

spo cdn get --type Public

查看 Office 365 CDN 來源View the Office 365 CDN origins

若要查看目前設定的 Office 365 公用 CDN 來源執行:To view the currently configured Office 365 Public CDN origins execute:

spo cdn origin list --type Public

請參閱 預設 CDN 來源 ,以取得啟用 OFFICE 365 CDN 時預設會提供之來源的詳細資訊。See Default CDN origins for information about the origins that are provisioned by default when you enable the Office 365 CDN.

新增 Office 365 CDN 原始Add an Office 365 CDN origin

重要

在設定為公用來源的 SharePoint 文件庫中,絕對不應將被視為敏感的資源放入組織中。You should never place resources that are considered sensitive to your organization in a SharePoint document library configured as a public origin.

使用 spo cdn 原始的 add 命令來定義 cdn 來源。Use the spo cdn origin add command to define a CDN origin. 您可以定義多個來源。You can define multiple origins. 來源是指向包含您要由 CDN 主控之資產的 SharePoint 文件庫或資料夾的 URL。The origin is a URL that points to a SharePoint library or folder that contains the assets that you want to be hosted by the CDN.

spo cdn origin add --type [Public | Private] --origin <path>

其中 path 是包含資產之資料夾的相對路徑。Where path is the relative path to the folder that contains the assets. 除了相對路徑之外,您還可以使用萬用字元。You can use wildcards in addition to relative paths.

若要將所有網站的 主版頁面圖庫 中的所有資產都包含為公用來源,請執行:To include all assets in the Master Page Gallery of all sites as a public origin, execute:

spo cdn origin add --type Public --origin */masterpage

若要設定特定網站集合的私人來源,請執行:To configure a private origin for a specific site collection, execute:

spo cdn origin add --type Private --origin sites/site1/siteassets

注意

新增 CDN 來源後,最多可能需要15分鐘的時間,您才可以透過 CDN 服務來取得檔案。After adding a CDN origin, it might take up to 15 minutes for you to be able to retrieve files via the CDN service. 您可以使用 spo cdn 原始清單 命令,確認是否已啟用特定來源。You can verify if the particular origin has already been enabled using the spo cdn origin list command.

移除 Office 365 CDN 原始Remove an Office 365 CDN origin

使用 spo cdn 原始移除 命令,為指定的 cdn 類型移除 cdn 來源。Use the spo cdn origin remove command to remove a CDN origin for the specified CDN type.

若要從 CDN 設定移除公用來源,請執行:To remove a public origin from the CDN configuration, execute:

spo cdn origin remove --type Public --origin */masterpage

注意

移除 CDN 原始檔不會影響與該來源相符的任何文件庫中儲存的檔案。Removing a CDN origin doesn't affect the files stored in any document library matching that origin. 如果這些資產已使用 SharePoint URL 參考,SharePoint 會自動切換回指向文件庫的原始 URL。If these assets have been referenced using their SharePoint URL, SharePoint will automatically switch back to the original URL pointing to the document library. 不過,如果資產已使用公用 CDN URL 參考,則移除該來源會中斷連結,您必須手動變更。If, however, assets have been referenced using a public CDN URL, then removing the origin will break the link and you will need to manually change them.

修改 Office 365 CDN 原始Modify an Office 365 CDN origin

不可能修改現有的 CDN 來源。It's not possible to modify an existing CDN origin. 相反地,您應該使用命令移除先前定義的 CDN 來源 spo cdn origin remove ,並使用命令新增新的 CDN 來源 spo cdn origin addInstead, you should remove the previously defined CDN origin using the spo cdn origin remove command and add a new one using the spo cdn origin add command.

變更要包含在 Office 365 CDN 中的檔案類型Change the types of files to include in the Office 365 CDN

根據預設,下列檔案類型會包含在 CDN: _.css、eot、.gif、.ico、.gif、.jpg、.js、.map、.gif、.jpg、ttf、woff 和 woff2_中。By default, the following file types are included in the CDN: .css, .eot, .gif, .ico, .jpeg, .jpg, .js, .map, .png, .svg, .ttf, .woff and .woff2. 如果您需要在 CDN 中包含其他檔案類型,您可以使用 spo CDN 原則組 命令變更 cdn 設定。If you need to include additional file types in the CDN, you can change the CDN configuration using the spo cdn policy set command.

注意

變更檔案類型的清單時,會覆寫目前定義的清單。When changing the list of file types, you overwrite the currently defined list. 如果您想要包含其他檔案類型,請先使用 spo cdn 原則清單 命令,找出目前設定的檔案類型。If you want to include additional file types, first use the spo cdn policy list command to find out which file types are currently configured.

若要將 JSON 檔案類型新增至公用 CDN 中所包含之檔案類型的預設清單,請執行:To add the JSON file type to the default list of file types included in the public CDN, execute:

spo cdn policy set --type Public --policy IncludeFileExtensions --value "CSS,EOT,GIF,ICO,JPEG,JPG,JS,MAP,PNG,SVG,TTF,WOFF,JSON"

變更您要從 Office 365 CDN 中排除的網站分類清單Change the list of site classifications you want to exclude from the Office 365 CDN

使用 spo cdn 原則組 命令,以排除您不想讓 CDN 在 cdn 上使用的網站分類。Use the spo cdn policy set command to exclude site classifications that you do not want to make available over the CDN. 根據預設,不會排除任何網站分類。By default, no site classifications are excluded.

注意

變更排除的網站分類清單時,會覆寫目前定義的清單。When changing the list of excluded site classifications, you overwrite the currently defined list. 若要排除其他分類,請先使用 spo cdn 原則清單 命令,找出目前設定的分類。If you want to exclude additional classifications, first use the spo cdn policy list command to find out which classifications are currently configured.

若要從公用 CDN 中排除歸類為 HBI 的網站,請執行To exclude sites classified as HBI from the public CDN, execute

spo cdn policy set --type Public --policy ExcludeRestrictedSiteClassifications --value "HBI"

停用 Office 365 CDNDisable the Office 365 CDN

若要停用 Office 365 CDN spo cdn set ,請使用命令,例如:To disable the Office 365 CDN use the spo cdn set command, for example:

spo cdn set --type Public --enabled false

使用 CDN 資產Using your CDN assets

現在,您已啟用 CDN 和設定的來源及原則,您可以開始使用 CDN 資產。Now that you have enabled the CDN and configured origins and policies, you can begin using your CDN assets.

本節將協助您瞭解如何在 SharePoint 頁面和內容中使用 CDN URLs,以 SharePoint 將公用和私人來源資產的要求重新導向至 CDN。This section will help you understand how to use CDN URLs in your SharePoint pages and content so that SharePoint redirects requests for assets in both public and private origins to the CDN.

如需如何使用 CDN 來主控用戶端網頁元件的詳細資訊,請參閱 從 Office 365 CDN (Hello World 第 4) 中的用戶端網頁元件 For information on how to use the CDN for hosting client-side web parts, see the topic Host your client-side web part from Office 365 CDN (Hello World part 4).

注意

如果您將 ClientSideAssets 資料夾新增至 私人 CDN 來源清單,則會無法轉譯 CDN 裝載的自訂網頁元件。If you add the ClientSideAssets folder to the private CDN origins list, CDN-hosted custom web parts will fail to render. SPFX 網頁元件使用的檔案只能利用公用 CDN,而 ClientSideAssets 資料夾是公用 CDN 的預設來源。Files used by SPFX web parts can only utilize the public CDN and the ClientSideAssets folder is a default origin for public CDN.

若要使用您已新增至來源的資產,您只需以原始檔案的路徑來更新原始檔案的連結。To use assets that you have added to an origin, you simply update links to the original file with the path to the file in the origin.

  • 編輯包含您已新增至來源之資產連結的頁面或內容。Edit the page or content that contains links to assets you have added to an origin. 您也可以使用其中一種方法,在 [輸入網站或網站集合] 中全域搜尋和取代連結,如果您想要在任何位置更新指定資產的連結。You can also use one of several methods to globally search and replace links across an enter site or site collection if you want to update the link to a given asset everywhere it appears.
  • 針對來源中資源的每個連結,以 CDN 原始檔的路徑取代路徑。For each link to an asset in an origin, replace the path with the path to the file in the CDN origin. 您可以使用相對路徑。You can use relative paths.
  • 儲存頁面或內容。Save the page or content.

例如,請考慮您已複製到文件庫資料夾 /site/CDN_origins/public/ 的影像 /site/SiteAssets/images/image.pngFor example, consider the image /site/SiteAssets/images/image.png, which you have copied to the document library folder /site/CDN_origins/public/. 若要使用 CDN 資產,請將原始路徑取代為來源路徑的圖像檔案位置,讓新的 URL /site/CDN_origins/public/image.pngTo use the CDN asset, replace the original path to the image file location with the path to the origin to make the new URL /site/CDN_origins/public/image.png.

如果您想要使用完整的 URL 來代替相對路徑,請建立如下的連結:If you want to use the full URL to the asset instead of a relative path, construct the link like so:

https://<TenantHostName>.sharepoint.com/sites/site/CDN_origins/public/image.png

注意

一般說來,您不應該直接對 CDN 中的資產進行硬編碼 URLs。In general, you should not hardcode URLs directly to assets in the CDN. 不過,您可以視需要,以手動方式為公用來源中的資產建立 URLs。However, you can manually construct URLs for assets in public origins if needed. 如需詳細資訊,請參閱 HARDCODING CDN URLs 的公開資產For more information, see Hardcoding CDN URLs for public assets.

若要瞭解如何驗證資產是否從 CDN 服務,請參閱如何在疑難排解 Office 365 CDN一節中,確認 CDN 是由 cdn 所服務To learn about how to verify that assets are being served from the CDN, see How do I confirm that assets are being served by the CDN? in the Troubleshooting the Office 365 CDN section.

使用公用來源中的資產Using assets in public origins

SharePoint Online 中的 發佈功能 會自動將儲存在公用來源中的資產 URLs 修正成其 CDN 對等專案,如此才能從 cdn 服務(而非 SharePoint)提供資產。The Publishing feature in SharePoint Online automatically rewrites URLs of assets stored in public origins to their CDN equivalents so that assets are served from the CDN service instead of SharePoint.

如果您的來源位於啟用發佈功能的網站中,且您想要將其轉移至 CDN 的資產屬於下列其中一個類別,則 SharePoint 會為來源中的資產自動重寫 URLs,但前提是該資產尚未由 CDN 原則排除。If your origin is in a site with the Publishing feature enabled, and the assets you want to offload to the CDN are in one of the following categories, SharePoint will automatically rewrite URLs for assets in the origin, provided that the asset has not been excluded by a CDN policy.

以下是 SharePoint 發佈功能會自動重新寫入連結的概覽:The following is an overview of which links are automatically rewritten by the SharePoint Publishing feature:

  • 傳統發佈頁面 HTML 回應中的 IMG/LINK/CSS URLsIMG/LINK/CSS URLs in classic publishing page HTML responses
    • 這包括網頁的 HTML 內容中作者所新增的影像This includes images added by authors within the HTML content of a page
  • 圖片庫幻燈片] 網頁元件影像 URLsPicture Library SlideShow webpart image URLs
  • SPList REST API (RenderListDataAsStream) 結果中的影像欄位Image fields in SPList REST API (RenderListDataAsStream) results
    • 使用新屬性 ImageFieldsToTryRewriteToCdnUrls 提供以逗號分隔的欄位清單Use the new property ImageFieldsToTryRewriteToCdnUrls to provide a comma separated list of fields
    • 支援 hyperlink 欄位及 PublishingImage 欄位Supports hyperlink fields and PublishingImage fields
  • SharePoint 影像轉譯SharePoint image renditions

下圖說明 SharePoint 接收公用來源中包含資產之頁面的要求時的工作流程。The following diagram illustrates the workflow when SharePoint receives a request for a page containing assets from a public origin.

工作流程圖表:從公用來源檢索 Office 365 CDN 資產Workflow diagram: Retrieving Office 365 CDN assets from a public origin

提示

如果您想要對頁面上的特定 URLs 停用自動重新寫入,您可以取出頁面並新增查詢字串參數 ?NoAutoReWrites = true 表示您要停用的每個連結的結尾。If you want to disable auto-rewriting for specific URLs on a page, you can check out the page and add the query string parameter ?NoAutoReWrites=true to the end of each link you want to disable.

Hardcoding 公用資產的 CDN URLsHardcoding CDN URLs for public assets

如果公開來源未啟用 發佈 功能,或資產並非 CDN 服務之自動重新寫入功能支援的連結類型之一,則可以手動構造資產的 cdn 位置的 URLs,並在內容中使用這些 URLs。If the Publishing feature is not enabled for a public origin, or the asset is not one of the link types supported by the auto-rewrite feature of the CDN service, you can manually construct URLs to the CDN location of the assets and use these URLs in your content.

注意

您無法對私人來源中的資產進行硬 URLs 編碼,因為在要求資源時,會產生表單最後一個區段所要求的訪問權杖。You cannot hardcode CDN URLs to assets in a private origin because the required access token that forms the last section of the URL is generated at the time the resource is requested.

若為公用 CDN 資產,URL 格式會類似如下:For public CDN assets, the URL format will look like the following:

https://publiccdn.sharepointonline.com/<TenantHostName>/sites/site/library/asset.png

TenantHostName 取代為您的租使用者名稱。Replace TenantHostName with your tenant name. 範例:Example:

https://publiccdn.sharepointonline.com/contoso.sharepoint.com/sites/site/library/asset.png

使用私人來源的資產Using assets in private origins

若要使用私人來源的資產,不需要進行其他設定。No additional configuration is required to use assets in private origins. SharePoint 線上針對私人來源中的資產自動重寫 URLs,因此這些資產的要求永遠會從 CDN 服務。SharePoint Online automatically rewrites URLs for assets in private origins so requests for those assets will always be served from the CDN. 您無法以私人來源手動建立 CDN 資產的 URLs,因為這些 URLs 包含在要求資產時 SharePoint 線上時必須自動產生的權杖。You cannot manually build URLs to CDN assets in private origins because these URLs contain tokens that must be auto-generated by SharePoint Online at the time the asset is requested.

存取私人來源資產的方法是根據原始的使用者權限,以使用者權限來保護,並在下列各節中說明的忠告。Access to assets in private origins is protected by dynamically generated tokens based on user permissions to the origin, with the caveats described in the following sections. 使用者必須至少具備 CDN 的「 讀取 」存取權,才能呈現內容。Users must have at least read access to the origins for the CDN to render content.

下圖說明 SharePoint 收到來自私人來源之資產的頁面要求時的工作流程。The following diagram illustrates the workflow when SharePoint receives a request for a page containing assets from a private origin.

工作流程圖表:從私人來源檢索 Office 365 CDN 資產Workflow diagram: Retrieving Office 365 CDN assets from a private origin

私人來源中以權杖為基礎的授權Token-based authorization in private origins

在 Office 365 CDN 中存取私人來源的資產是由 SharePoint Online 所產生的權杖所授。Access to assets in private origins in the Office 365 CDN is granted by tokens generated by SharePoint Online. 已有權存取原始位置所指定之資料夾或文件庫的使用者,會自動授與允許使用者根據其許可權層級存取該檔案的權杖。Users who already have permission to access to the folder or library designated by the origin are automatically granted tokens that permit the user to access the file based on their permission level. 這些存取權杖在產生後會有效30到90分鐘,以協助防止權杖重新顯示攻擊。These access tokens are valid for 30 to 90 minutes after they are generated to help prevent token replay attacks.

當存取權杖產生之後,SharePoint 線上傳回自訂 URI 至包含兩個授權參數的用戶端,將會 (edge authorization token) 和 oat (來源授權權杖) 。Once the access token is generated, SharePoint Online returns a custom URI to the client containing two authorization parameters eat (edge authorization token) and oat (origin authorization token). 每個權杖的結構是 _ 以時段格式「>< ' 安全簽名」 >< 的到期時間 _。The structure of each token is _<'expiration time in Epoch time format'><'secure signature'>_. 例如:For example:

https://privatecdn.sharepointonline.com/contoso.sharepoint.com/sites/site1/library1/folder1/image1.jpg?eat=1486154359_cc59042c5c55c90b26a2775323c7c8112718431228fe84d568a3795a63912840&oat=1486154359_7d73c2e3ba4b7b1f97242332900616db0d4ffb04312

注意

擁有該權杖的任何人都可以存取 CDN 中的資源。Anyone in possession of the token can access the resource in the CDN. 不過,包含這些存取權杖的 URLs 只會透過 HTTPS 共用,除非使用者在權杖到期之前明確共用該 URL,否則無法存取未授權使用者的資產。However, URLs containing these access tokens are only shared over HTTPS, so unless the URL is explicitly shared by an end user before the token expires, the asset won't be accessible to unauthorized users.

私人來源的資產不支援專案層級許可權Item-level permissions are not supported for assets in private origins

請務必注意,SharePoint Online 不支援私人來源資產的專案層級許可權。It is important to note that SharePoint Online does not support item-level permissions for assets in private origins. 例如,對於位於的檔案 https://contoso.sharepoint.com/sites/site1/library1/folder1/image1.jpg ,使用者會在發生下列情況時,具有檔案的有效存取權:For example, for a file located at https://contoso.sharepoint.com/sites/site1/library1/folder1/image1.jpg, users have effective access to the file given the following conditions:

使用者User 權限Permissions 有效的存取Effective access
使用者1User 1 可以存取 folder1Has access to folder1 可以從 CDN 存取 image1.jpgCan access image1.jpg from the CDN
使用者 2User 2 無權存取 folder1Does not have access to folder1 無法從 CDN 存取 image1.jpgCannot access image1.jpg from the CDN
使用者 3User 3 無權存取 folder1,但會授與在線上 SharePoint 中存取 image1.jpg 的明確許可權。Does not have access to folder1, but is granted explicit permission to access image1.jpg in SharePoint Online 可以直接從線上 SharePoint 存取資產 image1.jpg,但不能從 CDN 存取。Can access the asset image1.jpg directly from SharePoint Online, but not from the CDN
使用者 4User 4 可以存取 folder1,但已明確拒絕 SharePoint 線上中 image1.jpg 的存取權Has access to folder1, but has been explicitly denied access to image1.jpg in SharePoint Online 無法從 SharePoint 線上存取資產,但是可以存取 CDN 的資產,但不會拒絕存取 SharePoint 線上中的檔案。Cannot access the asset from SharePoint Online, but can access the asset from the CDN despite being denied access to the file in SharePoint Online

疑難排解 Office 365 CDNTroubleshooting the Office 365 CDN

如何確認 CDN 是否正在服務資產?How do I confirm that assets are being served by the CDN?

將 CDN 資產的連結新增至頁面後,您可以流覽至頁面,在圖像呈現及檢查影像 URL 後,以滑鼠右鍵按一下,以確認資產是否正在從 CDN 服務。Once you have added links to CDN assets to a page, you can confirm that the asset is being served from the CDN by browsing to the page, right clicking on the image once it has rendered and reviewing the image URL.

您也可以使用瀏覽器的開發人員工具,查看頁面上每個資產的 URL,或使用協力廠商網路追蹤工具。You can also use your browser's developer tools to view the URL for each asset on a page, or use a third party network trace tool.

注意

如果您使用 Fiddler 等網路工具在從 SharePoint 頁面轉譯資產之外測試資產,您必須手動將 referer 標頭 "Referer: https://yourdomain.sharepoint.com " 新增至 GET 要求,其中 URL 是您 SharePoint Online 租使用者的根 url。If you use a network tool such as Fiddler to test your assets outside of rendering the asset from a SharePoint page, you must manually add the referer header "Referer: https://yourdomain.sharepoint.com" to the GET request where the URL is the root URL of your SharePoint Online tenant.

您無法直接在網頁瀏覽器中測試 CDN URLs,因為您必須具有來自 SharePoint 線上的 referer。You cannot test CDN URLs directly in a web browser because you must have a referer coming from SharePoint Online. 不過,如果您將 CDN 資產 URL 新增至 SharePoint 頁面,然後在瀏覽器中開啟頁面,您會看到頁面上所呈現的 CDN 資產。However, if you add the CDN asset URL to a SharePoint page and then open the page in a browser, you will see the CDN asset rendered on the page.

如需使用 Microsoft Edge browser 中的開發人員工具的詳細資訊,請參閱 Microsoft Edge Developer toolsFor more information on using the developer tools in the Microsoft Edge browser, see Microsoft Edge Developer Tools.

若要觀看 SharePoint 開發人員模式和作法 中所主控的簡短影片 YouTube 通道示範如何驗證 cdn 是否正常運作,請參閱 驗證 cdn 使用方式和確保最佳的網路連線能力To watch a short video hosted in the SharePoint Developer Patterns and Practices YouTube channel demonstrating how to verify that your CDN is working, please see Verifying your CDN usage and ensuring optimal network connectivity.

為何無法使用來自新原始來源的資產?Why are assets from a new origin unavailable?

新的來源中的資產不會立即可供使用,因為註冊透過 CDN 傳播所需的時間,而且資產若要從來源上傳至 CDN 儲存區。Assets in new origins will not immediately be available for use, as it takes time for the registration to propagate through the CDN and for the assets to be uploaded from the origin to CDN storage. 在 CDN 中提供資產所需的時間取決於多少資產和檔案大小。The time required for assets to be available in the CDN depends on how many assets and the files sizes.

我的用戶端網頁元件或 SharePoint 架構解決方案無法運作My client-side web part or SharePoint Framework solution isn't working

當您為公用來源啟用 Office 365 CDN 時,CDN 服務會自動建立下列預設來源:When you enable the Office 365 CDN for public origins, the CDN service automatically creates these default origins:

  • */MASTERPAGE*/MASTERPAGE
  • */STYLE 程式庫*/STYLE LIBRARY
  • */CLIENTSIDEASSETS*/CLIENTSIDEASSETS

如果缺少 */clientsideassets 原創,SharePoint 架構解決方案將會失敗,而且不會產生警告或錯誤訊息。If the */clientsideassets origin is missing, SharePoint Framework solutions will fail, and no warning or error messages are generated. 因為啟用 -NoDefaultOrigins 參數設定為 $true,或已手動刪除來源,所以此來源可能遺失。This origin may be missing either because the CDN was enabled with the -NoDefaultOrigins parameter set to $true, or because the origin was manually deleted.

您可以使用下列 PowerShell 命令來查看存在哪些來源:You can check to see which origins are present with the following PowerShell command:

Get-SPOTenantCdnOrigins -CdnType Public

您也可以使用 Office 365 CLI 進行檢查:Or you can check with the Office 365 CLI:

spo cdn origin list

若要在 PowerShell: 中新增原點To add the origin in PowerShell:

Add-SPOTenantCdnOrigin -CdnType Public -OriginUrl */CLIENTSIDEASSETS

若要在 Office 365 CLI 中新增來源:To add the origin in the Office 365 CLI:

spo cdn origin add --origin */CLIENTSIDEASSETS

我需要哪些 PowerShell 模組和 CLI shell 才能搭配 Office 365 CDN 使用?What PowerShell modules and CLI shells do I need to work with the Office 365 CDN?

您可以選擇使用 SharePoint 線上管理命令 介面 PowerShell 模組或 Office 365 CLI來搭配 office 365 CDN。You can choose to work with the Office 365 CDN using either the SharePoint Online Management Shell PowerShell module or the Office 365 CLI.

請參閱See also

內容傳遞網路Content Delivery Networks

Office 365 的網路規劃和效能調整Network planning and performance tuning for Office 365

SharePoint 效能系列-Office 365 CDN 影片系列SharePoint Performance Series - Office 365 CDN video series