-
-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhanced Offline Support with Multi-Layer Caching in OWASP BLT #3933
Conversation
PR Reviewer Guide πHere are some key observations to aid the review process:
|
PR Code Suggestions β¨ |
This would be for the flutter app. |
Ok sir |
User description
π Offline-First Solution for OWASP BLT πβ¨
We successfully implemented a robust offline-first architecture for the OWASP BLT application, ensuring seamless functionality even in network disruptions. This includes:
πΉ Server-Side API Caching β Middleware (
NetworkStatusMiddleware
) to track network status, compatible with Django 5.1's async handling, and addsX-Network-Status
headers for client awareness.πΉ API Response Caching & Fallback β A
cache_api_response
decorator that stores responses in memory & filesystem, auto-detects network availability, and serves cached data when offline. IncludesApiCacheFallbackMiddleware
for resilient API handling.πΉ Image Caching System β Prevents broken images offline by storing them locally and replacing API response URLs with cached versions.
πΉ Client-Side Enhancements β IndexedDB-based caching, a Service Worker for offline asset management, and frontend modifications to handle offline scenarios gracefully.
πΉ Resilient Architecture β Background network checks, clear offline status indicators, and auto-sync when connectivity is restored.
π‘ Business Impact
Users can continue using the app seamlessly during network interruptions, ensuring a smooth experience with previously accessed content. This enhances reliability, especially for users with intermittent connectivity.
π Check it out:
Screen.Recording.2025-03-13.145535.mp4
π― Closes #3357
PR Type
Enhancement, Bug fix, Tests
Description
Introduced multi-layer caching for APIs and images to enhance offline support.
Added middleware for network status tracking and fallback to cached data.
Implemented client-side caching utilities for APIs and images using IndexedDB.
Updated templates to dynamically load statistics and handle offline scenarios.
Changes walkthrough π
10 files
Added dynamic stats loading with offline fallback.
Β Β Β Β Β Β ΒAdded scripts for API and image caching.
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β ΒIntegrated offline-first caching for API views.
Β Β Β Β Β Β Β Β Β ΒAdded utilities for API and image caching.
Β Β Β Β Β Β Β Β Β Β Β Β Β Β ΒIntroduced decorators for API caching and offline resilience.
Added middleware for API cache fallback.
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β ΒIntroduced middleware for network status tracking.
Β Β Β Β Β Β ΒImplemented client-side image caching utility.
Β Β Β Β Β Β Β Β Β Β ΒAdded network status detection and UI updates.
Β Β Β Β Β Β Β Β Β Β ΒDeveloped API caching utility for offline support.
Β Β Β Β Β Β Β2 files
Removed local mode panel and debug features.
Β Β Β Β Β Β Β Β Β Β Β Β ΒAdded package initialization for API functionality.
Β Β Β Β Β Β1 files
Configured caching settings and middleware integration.
Β Β1 files