Comments (8)
OK I found the issue.
I was using :
var requestUrl = new URL(event.request.url);
if (requestUrl.origin === location.origin) {
if ((requestUrl.pathname === '/')) {
event.respondWith(caches.match('/offline/'));
return;
}
}
event.respondWith(
caches.match(event.request).then(function(response) {
return response || fetch(event.request);
})
);
});
Instead of the original
event.respondWith(
caches.match(event.request)
.then(response => {
return response || fetch(event.request);
})
.catch(() => {
return caches.match('/offline/');
})
)
});
I have no idea why I did this...
Thanks goes to the rubber duck!
from django-pwa.
The default serviceworker.js works by listening for the response, and if the response status code is 200, then it will register a new cache, if NOT, call the page offline. The problem may be in the browser cache. I am sending a link to you about the serviceworker and hope this can help you https://developers.google.com/web/fundamentals/primers/service-workers/
from django-pwa.
Hello @pnaylor, are you trying to logout with internet on? If yes, it isn't using the serviceworker, but if No you should include the logout url in files To Cache on your custom servicework.js.
from django-pwa.
Thanks @silviolleite, it is online and on further testing only seems to be consistent on Firefox on macOS oddly. Not sure how it could not be the serviceworker though when unregistering it will fix the issue until it gets re-registered?
from django-pwa.
Not sure how this got originated still, but seem to have been able to get around it by clearing the site storage cache.
from django-pwa.
Hi,
We run into the same issue.
If LOGOUT_REDIRECT_URL is set to "/" Django will make a 302 and then the /offline template is rendered. But if I remove it I haven't the issue anymore.
Any idea how to make django-pwa handle 200 and 302 ?
from django-pwa.
BTW my logout url is like that:
url(r'^logout/(?P<next_page>.*)/$', LogoutView.as_view(), {'next_page': settings.LOGOUT_REDIRECT_URL}, name='logout'),
from django-pwa.
Had to remove the entire content inside the fetch callback function to stop running into this issue. Guess I need some more reading in order to understand how this really works
from django-pwa.
Related Issues (20)
- Django 4.2 : ResourceWarning: unclosed file serviceworker.js HOT 4
- Not Working
- Unknown Server running on localhost
- How can I cache the pages on the first load and then refresh homepage whenever user has internet connection?
- 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.