-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Dusting and cleaning of the web pages #13160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,15 @@ | ||
| --- | ||
| title: Web FAQ | ||
| description: Some gotchas and differences when writing or running web apps in Flutter. | ||
| description: >- | ||
| Some gotchas and differences when writing or running web apps in Flutter. | ||
| --- | ||
|
|
||
| ## Questions | ||
|
|
||
| ### What scenarios are ideal for Flutter on the web? | ||
|
|
||
| Not every web page makes sense in Flutter, but we think Flutter is particularly | ||
| suited for app-centric experiences: | ||
| Not every web page makes sense in Flutter, | ||
| but we think Flutter is particularly suited for app-centric experiences: | ||
|
|
||
| * Progressive Web Apps | ||
| * Single Page Apps | ||
|
|
@@ -25,33 +26,40 @@ see [Web support for Flutter][]. | |
|
|
||
| ### Search Engine Optimization (SEO) | ||
|
|
||
| In general, Flutter is geared towards dynamic application experiences. Flutter's | ||
| web support is no exception. Flutter web prioritizes performance, fidelity, and | ||
| consistency. This means application output does not align with what search | ||
| engines need to properly index. For web content that is static or document-like, | ||
| we recommend using HTML—just like we do on [flutter.dev]({{site.main-url}}), | ||
| [dart.dev]({{site.dart-site}}), and [pub.dev]({{site.pub}}). You should also | ||
| consider separating your primary application experience—created in Flutter—from | ||
| your landing page, marketing content, and help content—created using | ||
| search-engine optimized HTML. | ||
|
|
||
| That said, as mentioned in the [roadmap][], the Flutter team plans to | ||
| investigate search engine indexability of Flutter web. | ||
| In general, Flutter is geared towards dynamic application experiences. | ||
| Flutter's web support is no exception. | ||
| Flutter web prioritizes performance, fidelity, and consistency. | ||
| This means application output doesn't align with what search | ||
| engines need to properly index. | ||
|
|
||
| However, a community-released Dart package, [Jaspr][] _does_ | ||
| support static websites. | ||
| In fact, the [Dart documentation][] and [Flutter documentation][] and | ||
| [marketing][] websites were migrated to using the Jaspr package. | ||
|
|
||
| To summarize, for web content that is static or document-like, | ||
| we recommend _either_ using: | ||
|
|
||
| 1. [Jaspr][], if you want to use Dart but want a more traditional | ||
| DOM-based website. Also note that Jaspr makes SEO work in the | ||
| same way a traditional website would. | ||
| 1. HTML—in this case, consider separating your primary application | ||
| experience (created in Flutter), from your landing page, | ||
| marketing content, and help content (created using | ||
| search engine optimized HTML). | ||
|
|
||
| [Dart documentation]: {{site.dart-site}} | ||
| [Flutter documentation]: / | ||
| [Jaspr]: https://jaspr.site/ | ||
| [marketing]: {{site.main-url}} | ||
|
|
||
| ### Does hot reload work with a web app? | ||
|
|
||
| Yes! For more information, check out | ||
| [hot reload on the web][]. | ||
| Yes! For more information, | ||
| check out [hot reload on the web][]. | ||
|
|
||
| [hot reload on the web]: /platform-integration/web/building#hot-reload-web | ||
|
|
||
| Hot restart is a fast way of seeing your | ||
| changes without having to relaunch your web app and wait for it | ||
| to compile and load. This works similarly to | ||
| the hot reload feature for Flutter mobile development. | ||
| The difference is that hot reload remembers your state and hot | ||
| restart doesn't. | ||
|
|
||
| ### Which web browsers are supported by Flutter? | ||
|
|
||
| Flutter web apps can run on the 8000 following browsers: | ||
|
|
@@ -61,8 +69,9 @@ Flutter web apps can run on the following browsers: | |
| * Edge (mobile & desktop) | ||
| * Firefox (mobile & desktop) | ||
|
|
||
| During development, Chrome (on macOS, Windows, and Linux) and Edge (on Windows) | ||
| are supported as the default browsers for debugging your app. | ||
| During development, Chrome (on macOS, Windows, and Linux), | ||
| and Edge (on Windows) are supported as the default browsers | ||
| for debugging your app. | ||
|
|
||
| ### Can I build, run, and deploy web apps in any of the IDEs? | ||
|
|
||
|
|
@@ -106,28 +115,31 @@ See [Preparing a web app for release][]. | |
|
|
||
| ### Does `Platform.is` work on the web? | ||
|
|
||
| Not currently. | ||
| Not currently. Instead, | ||
| consider using the [`os_detect`][] package. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think support exists for kIsWeb - if this is for platform detection would should perhaps update this question here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting, @jonasfj asked for this fix. I'll see what he says when we reviews.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
But this question is written because historically lots of code has been using Using It's sadly technically allowed to On pub.dev, we will score packages as not supporting web if they import If you're coding a flutter app using If you are coding a package for use by others, you should probably prefer I think it's important to mention
I suspect the FAQ is here because Sorry, for all the rambling. This is complex to put it mildly -- generally, I think we should tell users to avoid
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it - appreciate the explanation here, @jonasfj! Since this is in the main FAQ for the web part of our docs, I think we should mention both then. kIsWeb for an app, and |
||
|
|
||
| ### Why doesn't my app update immediately after it's deployed? | ||
|
|
||
| You might need to configure the `Cache-Control` header returned by your web server. | ||
| For example, if this header is set to 3600, then the browser | ||
| and CDN will cache the asset for 1 hour, and your users might see an out-of-date | ||
| version of your app up to 1 hour after you deploy a new version. For | ||
| more information about caching on the web, | ||
| For example, if this header is set to 3600, | ||
| then the browser and CDN will cache the asset for 1 hour, | ||
| and your users might see an out-of-date | ||
| version of your app up to 1 hour after you deploy a new version. | ||
| For more information about caching on the web, | ||
| check out [Prevent unnecessary network requests with the HTTP Cache][http-cache]. | ||
|
|
||
| It is a good idea to be aware of this behavior to avoid an undesirable user experience. | ||
| It's a good idea to be aware of this behavior to avoid an undesirable user experience. | ||
| After you deploy your app, users might use a | ||
| cached version of your app (cached by the browser or CDN) | ||
| for the duration defined by your cache headers. | ||
| This can lead to users using a version of your app that | ||
| is incompatible with changes that have been deployed to backend services. | ||
|
|
||
| ### How do I clear the web cache after a deployment and force an app download? | ||
| If you wish to defeat these cache headers after each deployment, a common | ||
| technique is to append a build ID of some sort to the links of your static | ||
| resources, or update the filenames themselves. | ||
|
|
||
| If you wish to defeat these cache headers after each deployment, | ||
| a common technique is to append a build ID of some sort to the links | ||
| of your static resources, or update the filenames themselves. | ||
| For example, `logo.png` might become `logo.v123.png`. | ||
|
|
||
| ```html | ||
|
|
@@ -138,16 +150,17 @@ For example, `logo.png` might become `logo.v123.png`. | |
| <script src="flutter_bootstrap.v123.js" async></script> | ||
| ``` | ||
|
|
||
| Flutter does not currently support appending build IDs to resources | ||
| Flutter doesn't currently support appending build IDs to resources | ||
| automatically. | ||
|
|
||
| ### How do I configure my cache headers? | ||
|
|
||
| If you are using Firebase Hosting, | ||
| the shared cache (CDN) is invalidated when you deploy a new version of your | ||
| app. But you might choose to configure your cache headers as follows, | ||
| so that the browser cache doesn't cache application scripts, | ||
| but the shared cache does. | ||
| the shared cache (CDN) is invalidated when you deploy a | ||
| new version of your app. | ||
| However, to make sure that the browser doesn't | ||
| cache application scripts but the shared cache does, | ||
| you can configure your cache headers as follows, | ||
|
|
||
| ```json | ||
| { | ||
|
|
@@ -214,3 +227,4 @@ the `Cache-Control` header to a small value such as 0 or 60 seconds. | |
| [Web support for Flutter]: /platform-integration/web | ||
| [web workers]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers | ||
| [workbox]: https://github.com/GoogleChrome/workbox | ||
| [`os_detect`]: {{site.pub}}/packages/os_detect | ||
Uh oh!
There was an error while loading. Please reload this page.