Overview
This custom action ensures users always see the latest version of your FlutterFlow web app by comparing a hard‑coded current version with a remote value stored in Firebase Remote Config. If versions mismatch, it signals the UI to prompt a forced refresh, overcoming browser caching and local storage persistence. This acts more as a workaround since FlutterFlow doesn't allow direct control over browser caching strategies while still hosting the code within its platform. This therefore avoids exporting exporting code and manually modifying caching behaviour.
Dependencies
- firebase_remote_config: Flutter plugin for Firebase Remote Config
- dart:html: For browser localStorage and page reload (window.location.reload())
How It Works
- Version Comparison
- Compares the hard-coded “currentVersion” from the custom action to the remote “latest_version” value in Firebase.
- The custom action then either returns “true” for a match and otherwise “false”
- Cache Bypass
- Sets minimumFetchInterval to zero to always fetch new values from Remote Config.
- If versions differ, writes a flag to localStorage and calls window.location.reload() to try force a hard refresh.
- Loop Protection
- Checks localStorage[’refreshTriggered’] so that after a reload, it won’t immediately reload again.
- User Prompt
Note: More often than not the refresh method might not work in the users browsers or for all users due to browser caching or settings.
- If the refresh doesn't work automatically, a UI prompt is shown to the user instructing them to press Ctrl + Shift + r (or the equivalent for their browser) to manually trigger a full refresh and see the updated content. (see example of UI at the bottom of this doc).
Setup Instructions
- Add Custom Action and configure with Firebase
- Below is the custom action logic, named “checkAppVersion”.
- In Firebase Console, go to Remote Config and create a parameter called “latest_version”, and set its value to the current app version (e.g., 1.0.1).
- When Publishing Changes
- Before republishing your web app with new changed, increment both:
- The **hard-coded “**currentVersion” constant in the custom action (e.g., from 1.0.1 to 1.0.2).
- The Remote Config parameter “latest_version” in your Firebase Console.
- Invoke on Load
- Add checkAppVersion as an On Page Load action in your home screen or suitable alternative.
- If the action returns “false” display a modal prompting the user to refresh (see example of UI at the bottom of this doc).
Custom Action Logic