Skip to content

[package_info_plus] Web: Version info may be stale due to caching. #225

Closed

Description

@eggnstone

System info

Issue occurs on: Web only
Plugin name: package_info_plus
Plugin version: 1.0.0
Flutter doctor output:

flutter doctor -v
[√] Flutter (Channel beta, 2.2.0-10.1.pre, on Microsoft Windows [Version 10.0.19042.928], locale en-DE)
    • Flutter version 2.2.0-10.1.pre at C:\xyz
    • Framework revision 0941968447 (11 days ago), 2021-04-15 12:01:02 -0700
    • Engine revision d2a2e93510
    • Dart version 2.13.0 (build 2.13.0-211.6.beta)

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\xyz
    • Platform android-S, build-tools 30.0.3
    • ANDROID_HOME = C:\xyz
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 3.6)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 49.0.1
    • Dart plugin version 192.8052
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[√] IntelliJ IDEA Ultimate Edition (version 2019.3)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2019.1.1
    • Flutter plugin version 44.0.3
    • Dart plugin version 193.6911.31

[√] IntelliJ IDEA Ultimate Edition (version 2020.3)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2020.2.2
    • Flutter plugin version 54.1.4
    • Dart plugin version 203.7759

[√] VS Code (version 1.54.3)
    • VS Code at C:\xyz
    • Flutter extension version 3.18.1

[√] Connected device (2 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 90.0.4430.85
    • Edge (web)   • edge   • web-javascript • Microsoft Edge 90.0.818.46

• No issues found!

Steps to Reproduce

  • use package_info_plus to display version info
  • build & deploy to Firebase Hosting
  • verify version info on hosted version
  • update version numbers
  • build & deploy to Firebase Hosting
  • notice old version displayed

My analysis is that package_info_plus uses the data from https://.../version.json.
Firebase Hosting caches this file and may hand out an old version of this file.

Suggestion: add a cachebuster:

// 2^32 max value according to https://api.dart.dev/stable/2.12.4/dart-math/Random/nextInt.html
final cachebuster = Random().nextInt(2^32); 
final url = Uri.parse(
    '${Uri.parse(window.document.baseUri!).removeFragment()}version.json?cachebuster=$cachebuster');

Activity

  1. mhadaily commented on Jun 7, 2021

    @mhadaily
    Member

    This could work #284

    While the PR will resolve this issue, we would like to see other options for example padding an input variable for busting caching, for PWA offline purposes, it's nice to have a unique number after each build so we can cache the request. There are a few discussion on going on flutter repo such as this one flutter/flutter#63500, it's nice to keep an eye on them.

  2. mhadaily commented on Jun 7, 2021

    @mhadaily
    Member

    new version released #284

  3. alextekartik commented on Sep 14, 2021

    @alextekartik

    Now the issue is that it no longer works offline...

  4. locked as resolved and limited conversation to collaborators on Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackage_info_plusstuff related to package_info_plusweb

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions