<-- Back

PWA offline profile serves cached pages instead of the online profile after navigating to an offline page

Issue

When a Mendix application has both Responsive Web and Responsive Web Offline profiles configured in the navigation, a page accessed with ?profile=Responsive is no longer opened correctly after an offline page has been visited.

To reproduce the issue, follow these steps:

  1. Navigate to a page that has ?profile=Responsive in the URL. The page loads correctly using the online profile.
  2. Navigate to another page without specifying the profile query parameter. This page opens using the offline profile.
  3. Navigate back to the original page using ?profile=Responsive. Instead of loading the online profile, the browser continues to serve the cached page from the offline profile.

Environment

Studio Pro (all versions)

Cause

When a Mendix application has both Responsive Web and Responsive Web Offline profiles configured in the navigation, it is treated as an Offline-First application. As a result, pages are opened using the offline profile by default. Although the online profile can be accessed intentionally by adding ?profile=Responsive to the URL, the profile query parameter is intended only for previewing a specific profile and should not be used as the default way to access the application. If ?profile=Responsive is not included in the URL, the offline profile is used by default.

When the offline profile is accessed for the first time, the browser registers a service worker that pre-caches application resources so they are available without an internet connection.

Once the service worker has been registered, its cache is not invalidated when switching back to the online profile by using ?profile=Responsive. As a result, cached content from the offline profile continues to be served instead of fetching the latest content from the online profile.

Solution/Workaround

If the application is intended to have offline functionality, configure the entire application as an offline application by following the Mendix Offline-First Data documentation. This ensures consistent and expected behavior across all profiles and navigation flows, and the service worker operates as designed.

Internal information related

  • 281964
  • CJZ85RLTA/p1782728582241569

Additional information

Mendix documentation:

Have more questions? Submit a request

0 Comments

Article is closed for comments.

To provide feedback, please open a ticket here. Don't forget to include the article's URL along with the feedback you would like to provide.