Comments (6)
Hello,
@saileshkush95 @i-konuk
I was able to fix it by creating my own service worker and then point at it using the PWA_SERVICE_WORKER_PATH variable (PWA_APP_FETCH_URL is passed through).
PWA_SERVICE_WORKER_PATH = os.path.join(BASE_DIR, 'my_app', 'serviceworker.js')
This problem is due to the fact that Django cannot find all the static files listed in the Serviceworker.js file, so you should create a custom service worker, copy the exact one from the documentation and delete the url to files that do not exist on your server or edit the url to the correct one and it should work fine.
from django-pwa.
My Example Service worker.
// Base Service Worker implementation. To use your own Service Worker, set the PWA_SERVICE_WORKER_PATH variable in settings.py
var staticCacheName = "django-pwa-v" + new Date().getTime();
var filesToCache = [
// '/offline',
'https://my-app.s3.amazonaws.com/static/images/my_app_icon2.png',
'https://my-app.s3.amazonaws.com/static/images/pwa-app-icon.png',
];
// Cache on install
self.addEventListener("install", event => {
this.skipWaiting();
event.waitUntil(
caches.open(staticCacheName)
.then(cache => {
return cache.addAll(filesToCache);
})
)
});
// Clear cache on activate
self.addEventListener('activate', event => {
event.waitUntil(
caches.keys().then(cacheNames => {
return Promise.all(
cacheNames
.filter(cacheName => (cacheName.startsWith("django-pwa-")))
.filter(cacheName => (cacheName !== staticCacheName))
.map(cacheName => caches.delete(cacheName))
);
})
);
});
// Serve from Cache
self.addEventListener("fetch", event => {
event.respondWith(
caches.match(event.request)
.then(response => {
return response || fetch(event.request);
})
.catch(() => {
return caches.match('offline');
})
)
});
from django-pwa.
Fixed.
from django-pwa.
Fixed.
I have the same issue. Could you please share the solution?
from django-pwa.
I'm also facing same problem
from django-pwa.
Fixed.
I have the same issue. Could you please share the solution?
Hello,
I was able to fix it by creating my own service worker and then point at it using the PWA_SERVICE_WORKER_PATH variable (PWA_APP_FETCH_URL is passed through).
PWA_SERVICE_WORKER_PATH = os.path.join(BASE_DIR, 'my_app', 'serviceworker.js')
from django-pwa.
Related Issues (20)
- Django 4.2 : ResourceWarning: unclosed file serviceworker.js HOT 4
- Not Working
- Unknown Server running on localhost
- PWA_APP_ICONS_APPLE Setting Not Recognized Due to Absence in app_settings.py HOT 1
- Package installs tests to "site-packages/tests" directory
- Not Installing as webapks HOT 2
- Django Debug Screen is replaced by 'offline page'
- Deprecation warning for `django.conf.urls.url()` HOT 1
- Short Name Setting Not Added
- service-worker.js loading is Unconventional HOT 1
- Hi @silviolleite, where can I find the version 1.0.2? the latest version is showing 1.0.10? HOT 1
- App Screenshots and Descriptions.
- Every GET fetches ServiceWorker.js
- jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'load'.
- Compatibility Issue with Django 4.0 HOT 8
- Release? HOT 2
- How to solve compatibility with django 4. HOT 4
- add the urls.py to releases HOT 2
- Can the application be published to app store? HOT 3
- Install popup in not showing in domain hosted in AWS EC2 but working in localhost HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-pwa.