Repository: flutter
Issue: [Web] if web is hosted in sub path, service worker cache doesn't work.
Labels: tool,platform-web,has reproducible steps,P2,found in release: 3.3,e: flutter.js,found in release: 3.4,team-web,triaged-web

<!-- Thank you for using Flutter!

     If you are looking for support, please check out our documentation
     or consider asking a question on Stack Overflow:
      * https://flutter.dev/
      * https://api.flutter.dev/
      * https://stackoverflow.com/questions/tagged/flutter?sort=frequent

     If you have found a bug or if our documentation doesn't have an answer
     to what you're looking for, then fill out the template below. Please read
     our guide to filing a bug first: https://flutter.dev/docs/resources/bug-reports
-->

## Steps to Reproduce

<!-- Please include full steps to reproduce so that we can reproduce the problem. -->

1. Create a sample application project.
2. Build Flutter web and move to a directory.
```shell
flutter build web --release --base-href=/sub/
mkdir -p release/sub && cp -a build/web/* release/sub
```
3. Host Flutter web by http-server. 
```shell
http-server release
```
4. Open Chrome and dev-tools, then load `http:127.0.0.1:8080/sub`
5. At first time loading the web, web will install service_worker and cache files by flutter_service_worker.js CORE and RESOURCES rule. And then refresh the web. You could inspect all network request at Network tab. I expect files like main.dart.js should comes from service_worker rather than disk cache directly.

**Expected results:** <!-- what did you want to see? -->

<img width="1440" alt="截圖 2022-09-19 下午4 39 33" src="https://user-images.githubusercontent.com/14304782/190980580-5a721c16-a9cb-4916-9b1e-53bd2c231c3f.png">

**Actual results:** <!-- what did you see? -->

<img width="1440" alt="截圖 2022-09-19 下午4 42 20" src="https://user-images.githubusercontent.com/14304782/190980703-f32f4115-5045-4d42-80d9-33bf90742629.png">

<details>
<summary>Code sample</summary>

<!--
      Please create a minimal reproducible sample that shows the problem
      and attach it below between the lines with the backticks.

      To create it you can use `flutter create bug` command and update the `main.dart` file.

      Alternatively, you can use https://dartpad.dev/
      which is capable of creating and running small Flutter apps.

      Without this we will unlikely be able to progress on the issue, and because of that
      we regretfully will have to close it.
-->
```
This issue is related web host bug. It is hard to provide a code sample.
```
</details>

<details>
  <summary>Logs</summary>

<!--
      Run your application with `flutter run --verbose` and attach all the
      log output below between the lines with the backticks. If there is an
      exception, please see if the error message includes enough information
      to explain how to solve the issue. If there is a crash, please include
      the entirety of the crash log including the backtrace.
-->

```
I think the screenshot is enough.
```

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
Analyzing service_worker_demo...                                
No issues found! (ran in 1.2s)
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
[✓] Flutter (Channel stable, 3.3.2, on macOS 12.6 21G115 darwin-arm, locale zh-Hant-TW)
    • Flutter version 3.3.2 on channel stable at /Users/jimmy/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision e3c29ec00c (5 days ago), 2022-09-14 08:46:55 -0500
    • Engine revision a4ff2c53d8
    • Dart version 2.18.1
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/jimmy/Library/Android/sdk
    • Platform android-32, build-tools 32.1.0-rc1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13C100
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)

[✓] VS Code (version 1.71.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.48.0

[✓] Connected device (2 available)
    • JimmyTai-iPhone (mobile) • 053fa2bd7d1c65719ac672c401f6c823ccb4b614 • ios            • iOS 15.3.1 19D52
    • Chrome (web)             • chrome                                   • web-javascript • Google Chrome 105.0.5195.125

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
```

</details>


<!--
      Consider also attaching screenshots and/or videos to better
      illustrate the issue.

      You can upload them directly on GitHub.
      Beware that video file size is limited to 10MB.
-->