All Projects → petrbroz → forge-disconnected

petrbroz / forge-disconnected

Licence: other
Sample Forge application using Service Workers and Cache APIs to provide a limited offline support.

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to forge-disconnected

forge-digital-twin
Autodesk Forge application demonstrating various use cases in manufacturing, specifically in context of digital twins.
Stars: ✭ 95 (+533.33%)
Mutual labels:  autodesk-forge
mswjs.io
Official website and documentation for the Mock Service Worker library.
Stars: ✭ 77 (+413.33%)
Mutual labels:  service-worker
badaso
The API & platform builder, build your apps 10x faster even more, it's open source & 100% free !
Stars: ✭ 650 (+4233.33%)
Mutual labels:  service-worker
webpush-example
A basic push notifications app built on Laravel and Vanilla Javascript.
Stars: ✭ 26 (+73.33%)
Mutual labels:  service-worker
data-transport
A generic and responsible communication transporter(iframe/Broadcast/Web Worker/Service Worker/Shared Worker/WebRTC/Electron, etc.)
Stars: ✭ 27 (+80%)
Mutual labels:  service-worker
Prelude
A web app for practicing musical sight reading skills
Stars: ✭ 24 (+60%)
Mutual labels:  service-worker
angular-8-boilerplate
Angular 8 Boilerplate with bootstrap
Stars: ✭ 23 (+53.33%)
Mutual labels:  service-worker
polymerx-cli
⚡ Unlock the power of Polymer 3, Web Components and modern web tools.
Stars: ✭ 30 (+100%)
Mutual labels:  service-worker
react-app-rewire-workbox
Customise the service worker for create-react-app apps without ejecting - using Google's Workbox webpack plugins instead of the old sw-precache
Stars: ✭ 44 (+193.33%)
Mutual labels:  service-worker
jekyll-pwa-workbox
A Jekyll plugin using Workbox to make your PWA / Website available offline.
Stars: ✭ 22 (+46.67%)
Mutual labels:  service-worker
wordpress-pwacommerce
PWACommerce - WooCommerce Mobile Plugin for Progressive Web Apps & Hybrid Mobile Apps
Stars: ✭ 20 (+33.33%)
Mutual labels:  service-worker
clean-to-the-core
🍏 A gluten free, accessible, offline-first, progressive web app for creating healthy meals.
Stars: ✭ 12 (-20%)
Mutual labels:  service-worker
react-prpl-boilerplate
A simple boilerplate for learn PRPL pattern with React.
Stars: ✭ 23 (+53.33%)
Mutual labels:  service-worker
react-weather-app
⛅️ PWA Weather App made with ReactJS
Stars: ✭ 147 (+880%)
Mutual labels:  service-worker
egg-typescript-element-kit
基于 Egg + TypeScript + Element 博客系统,包括前台系统和后台管理系统
Stars: ✭ 19 (+26.67%)
Mutual labels:  service-worker
pushercoins
A React.js PWA with realtime features accompanying the tutorial on the Pusher blog.
Stars: ✭ 66 (+340%)
Mutual labels:  service-worker
block service workers
Extension to block Service Workers registration in Chrome (also see https://shadow-workers.github.io )
Stars: ✭ 29 (+93.33%)
Mutual labels:  service-worker
service-worker-exercises
Get started with Service Worker
Stars: ✭ 37 (+146.67%)
Mutual labels:  service-worker
mercury
A serverless, clean, and persistent note dump that works fully offline
Stars: ✭ 19 (+26.67%)
Mutual labels:  service-worker
http4s-dom
http4s, in a browser near you
Stars: ✭ 13 (-13.33%)
Mutual labels:  service-worker

forge-disconnected

Sample Autodesk Forge application using Service Workers and Cache APIs to provide a limited offline support, allowing you to cache selected models and view them without internet connection.

Live demo is available at https://forge-disconnected.autodesk.io.

Running locally

  • Install dependencies: npm install
  • Define your FORGE_CLIENT_ID, FORGE_CLIENT_SECRET, and FORGE_BUCKET env. variables
  • Run the server: npm start
  • Go to localhost:3000
  • After loading one of the example models, you should see a symbol next to its name, indicating that the model can now be cached
  • Click the symbol; after a moment it should change to , indicating that the model has now been successfully cached
  • Go offline and open any of the models with next to their name
  • Click on any of the symbols to clear the cache for the corresponding model

Debugging

In Chrome, the Application tab of the DevTools provides many useful tools for working with service workers. The Service Workers section shows any running workers, provides links to their source code, and allows you to update or unregister them. In the Cache Storage section you'll find the cache objects associated with the corresponding site.

Chrome - Service Workers

Chrome - Cache Objects

In Firefox, you can use the about:serviceworkers or about:debugging#workers URL to get a detailed information about service workers currently registered for various websites.

Firefox - Service Workers

Caching strategy

Static assets and known APIs are cached immediately when the service worker is installed, see the STATIC_URLS and API_URLS constants in the worker script.

Note that in our case we only cache a subset of the viewer's assets, e.g., only two environments are cached: Sharp Highlighs and Boardwalk. If you want to include other static assets, perhaps including your own viewer extensions, don't forget to include them in the list.

A single document in Forge typically generates multiple derivatives, and derivatives themselves often reference additional assets. We need a way to identify these assets in order to cache them when needed. In this sample application, the server provides a GET /api/models/:urn/files endpoint which is inspired by https://extract.autodesk.io and - given a document URN - provides a list of URLS for all derivatives and their assets.

Known issues & gotchas

  • Service workers are only enabled in HTTPS context; one exception to this is when serving from localhost in which case it can be HTTP
    • At one point during the development, I noticed that the service workers were not enabled in Google Chrome when served from http://localhost; as of now (with Chrome version 69.0.3497.100), localhost is working fine again
  • Service worker can only manage requests in its own subpath; for example, if you serve your service worker script from /javascript/service-worker.js, it won't be able to intercept requests to /stylesheets/main.css
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].