Principle:Langgenius Dify PWA Support
| Knowledge Sources | Dify |
|---|---|
| Domains | Frontend, PWA |
| Last Updated | 2026-02-12 07:00 GMT |
Overview
Progressive Web App capabilities through Serwist service worker with precaching and offline support, enabling the Dify frontend to function as an installable, offline-capable application.
Description
The PWA Support principle defines how Dify implements Progressive Web App capabilities to enhance the user experience beyond what a traditional web application offers. Using Serwist (a modern service worker toolkit), the frontend precaches critical assets during installation and serves them from cache during subsequent visits, providing faster load times and offline resilience.
In the Dify codebase, PWA support is woven into both the root layout and a dedicated service worker file. The root layout includes the necessary metadata, manifest links, and theme color declarations that browsers use to determine PWA eligibility. The service worker, built with Serwist, defines precaching strategies for static assets and runtime caching strategies for API responses. This dual integration ensures that both the HTML shell and the dynamic content benefit from caching optimizations.
This principle matters because Dify is designed to be a daily-use tool for LLM application development. PWA capabilities allow users to install the application on their desktop or mobile device, receive a native-like experience with fast startup times, and continue accessing cached content even when network connectivity is unreliable. For teams operating in environments with intermittent connectivity or strict security policies that limit browser tabs, the installable PWA experience provides a more robust and accessible interface.
Usage
Use this principle when:
- Modifying caching strategies for new asset types or API endpoints
- Updating the service worker lifecycle (install, activate, fetch handlers)
- Adding new features that need to work in offline or degraded network conditions
Theoretical Basis
Progressive Web Apps are built on three core web platform technologies: Service Workers (background scripts that intercept network requests), the Cache API (programmatic control over cached responses), and the Web App Manifest (metadata enabling installation). The precaching strategy follows the Cache-First pattern for static assets, ensuring instant loads from cache, while dynamic content may use Stale-While-Revalidate to balance freshness with performance.