Giter Club home page Giter Club logo

Comments (8)

VivienGiraud avatar VivienGiraud commented on August 22, 2024 3

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.

silviolleite avatar silviolleite commented on August 22, 2024 1

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.

silviolleite avatar silviolleite commented on August 22, 2024

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.

pnaylor avatar pnaylor commented on August 22, 2024

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.

pnaylor avatar pnaylor commented on August 22, 2024

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.

VivienGiraud avatar VivienGiraud commented on August 22, 2024

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.

VivienGiraud avatar VivienGiraud commented on August 22, 2024

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.

Olfredos6 avatar Olfredos6 commented on August 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.