From 926c398fabd5f56755680c509a42fe36c8f0a6bf Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Wed, 8 Sep 2021 08:36:39 -0500 Subject: [PATCH] Blazor JS file cache/no-cache guidance (#23235) --- .../javascript-interoperability/index.md | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/aspnetcore/blazor/javascript-interoperability/index.md b/aspnetcore/blazor/javascript-interoperability/index.md index bc220c156d..2a2329ba49 100644 --- a/aspnetcore/blazor/javascript-interoperability/index.md +++ b/aspnetcore/blazor/javascript-interoperability/index.md @@ -176,6 +176,25 @@ JS isolation provides the following benefits: For more information, see . +## Cached JavaScript files + +JavaScript (JS) files and other static assets aren't generally cached on clients during development in the [`Development` environment](xref:fundamentals/index#environments). During development, static asset requests include the [`Cache-Control` header](https://developer.mozilla.org/docs/Web/HTTP/Headers/Cache-Control) with a value of [`no-cache`](https://developer.mozilla.org/docs/Web/HTTP/Headers/Cache-Control#cacheability) or [`max-age`](https://developer.mozilla.org/docs/Web/HTTP/Headers/Cache-Control#expiration) with a value of zero (`0`). + +During production in the [`Production` environment](xref:fundamentals/index#environments), JS files are usually cached by clients. + +To disable client-side caching in browsers, developers usually adopt one of the following approaches: + +* Disable caching when the browser's developer tools console is open. Guidance can be found in the developer tools documentation of each browser maintainer: + * [Chrome DevTools](https://developer.chrome.com/docs/devtools/) + * [Firefox Developer Tools](https://developer.mozilla.org/docs/Tools) + * [Microsoft Edge Developer Tools overview](/microsoft-edge/devtools-guide-chromium/) +* Perform a manual browser refresh of any webpage of the Blazor app to reload JS files from the server. ASP.NET Core's HTTP Caching Middleware always honors a valid no-cache [`Cache-Control` header](https://developer.mozilla.org/docs/Web/HTTP/Headers/Cache-Control) sent by a client. + +For more information, see: + +* +* + ::: moniker-end ::: moniker range=">= aspnetcore-5.0 < aspnetcore-6.0" @@ -343,6 +362,25 @@ JS isolation provides the following benefits: For more information, see . +## Cached JavaScript files + +JavaScript (JS) files and other static assets aren't generally cached on clients during development in the [`Development` environment](xref:fundamentals/index#environments). During development, static asset requests include the [`Cache-Control` header](https://developer.mozilla.org/docs/Web/HTTP/Headers/Cache-Control) with a value of [`no-cache`](https://developer.mozilla.org/docs/Web/HTTP/Headers/Cache-Control#cacheability) or [`max-age`](https://developer.mozilla.org/docs/Web/HTTP/Headers/Cache-Control#expiration) with a value of zero (`0`). + +During production in the [`Production` environment](xref:fundamentals/index#environments), JS files are usually cached by clients. + +To disable client-side caching in browsers, developers usually adopt one of the following approaches: + +* Disable caching when the browser's developer tools console is open. Guidance can be found in the developer tools documentation of each browser maintainer: + * [Chrome DevTools](https://developer.chrome.com/docs/devtools/) + * [Firefox Developer Tools](https://developer.mozilla.org/docs/Tools) + * [Microsoft Edge Developer Tools overview](/microsoft-edge/devtools-guide-chromium/) +* Perform a manual browser refresh of any webpage of the Blazor app to reload JS files from the server. ASP.NET Core's HTTP Caching Middleware always honors a valid no-cache [`Cache-Control` header](https://developer.mozilla.org/docs/Web/HTTP/Headers/Cache-Control) sent by a client. + +For more information, see: + +* +* + ::: moniker-end ::: moniker range="< aspnetcore-5.0" @@ -499,4 +537,24 @@ The `{webassembly|server}` placeholder in the preceding markup is either `webass For more information on Blazor startup, see . + +## Cached JavaScript files + +JavaScript (JS) files and other static assets aren't generally cached on clients during development in the [`Development` environment](xref:fundamentals/index#environments). During development, static asset requests include the [`Cache-Control` header](https://developer.mozilla.org/docs/Web/HTTP/Headers/Cache-Control) with a value of [`no-cache`](https://developer.mozilla.org/docs/Web/HTTP/Headers/Cache-Control#cacheability) or [`max-age`](https://developer.mozilla.org/docs/Web/HTTP/Headers/Cache-Control#expiration) with a value of zero (`0`). + +During production in the [`Production` environment](xref:fundamentals/index#environments), JS files are usually cached by clients. + +To disable client-side caching in browsers, developers usually adopt one of the following approaches: + +* Disable caching when the browser's developer tools console is open. Guidance can be found in the developer tools documentation of each browser maintainer: + * [Chrome DevTools](https://developer.chrome.com/docs/devtools/) + * [Firefox Developer Tools](https://developer.mozilla.org/docs/Tools) + * [Microsoft Edge Developer Tools overview](/microsoft-edge/devtools-guide-chromium/) +* Perform a manual browser refresh of any webpage of the Blazor app to reload JS files from the server. ASP.NET Core's HTTP Caching Middleware always honors a valid no-cache [`Cache-Control` header](https://developer.mozilla.org/docs/Web/HTTP/Headers/Cache-Control) sent by a client. + +For more information, see: + +* +* + ::: moniker-end