Skip to content
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

tentative plan for implementing offline support? #5

Open
jantech opened this issue Feb 29, 2024 · 4 comments
Open

tentative plan for implementing offline support? #5

jantech opened this issue Feb 29, 2024 · 4 comments

Comments

@jantech
Copy link

jantech commented Feb 29, 2024

Hi,

Do you have plan for implementing below offline support features mentioned?

Thoughts and to dos:

  1. How can we capture form POSTs when offline, to send them when the network comes back up?
  2. What's the best way to prevent certain user actions when offline?
  3. How can we disable caching on certain URLs? (Useful for lazy loading quick-changing content).

Thanks

@g105b
Copy link
Owner

g105b commented Feb 29, 2024

Hi @jantech ,

Yes I do have some thoughts, and one day I will get around to implementing them. All of the above can be achieved with the service worker. At the moment, the service worker will respond with the latest cached page when offline, but it does this without applying any logic.

We can add some logic to the SW that takes a POST request and adds it to a queue for later processing. Then when the SW detects that the network is online again, it can send the requests to the server and update the client with delivery status.

This is easy to type up my ideas, but I'm aware that in the real world there are many scenarios that need to be covered, and I don't want to implement something half-baked.

I will revisit the to dos on this project in time, but at the moment I am too busy with paid projects to invest my time into things like this.

More reading: the fetch event can be intercepted whenever the browser makes a new network request. the actual Request object can be cached/queued, and then dealt with when the network status changes.

Hope the links help show you my plans. If you feel like contributing any changes, I'm happy to help guide you, but at the moment I can't commit any time to the project.

@jantech
Copy link
Author

jantech commented Mar 1, 2024

Thanks @g105b , for your reply.

Looking forward for the To Dos get implemented. will be waiting for the updates.

Thanks,
Jagan

@eren-cantemur
Copy link

Would love to talk about ideas on the topic. We also need the offline support and we are trying to come up with a way.

@g105b
Copy link
Owner

g105b commented Mar 20, 2024

Hi @jantech and @eren-cantemur - this is something that I'm currently working on. Catching the requests from a form while offline, so it can be sent to the server when back online.

Trying to keep it simple and generic so it can be applied to any project.

I'm currently working on another project but as soon as I get time I'll finish this idea off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants