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

Offline support #1888

Closed
wants to merge 37 commits into from
Closed

Conversation

zadeviggers
Copy link
Contributor

@zadeviggers zadeviggers commented Oct 22, 2022

Description

Work on adding opt-in, network-first (to keep content up-to-date), offline support to the docs site.

This is very much a WIP PR. There's still a lot of work to do before this is ready. I'm just creating this PR so that people have something to look at in the community call on Wednesday.

Big things still to do:

  • Basic offline support
  • Prioritise caching important assets, like CSS
  • Generate a unique hash on each build to use to invalidate the cache
  • Only cache pages in the user's selected language
  • Prioritise downloading pages the user currently has open
  • Fix long page loading time when offline.
  • Indicate to the user whether a page was served from the offline cache or not
  • More messaging to the user about the system status - installing, downloading content, removing, etc
  • Make all strings in UI translatable
  • Remove dependency on simple-vanilla-notifications?
  • Clean up & comment code
  • Fix translation not working in client-side scripts
  • Move to external package

FAQ:

  • Does it work in dev mode? No - the service worker needs to be able to get a list of generated routes to be able to cache stuff, and that can only happen at build time. This is good because the service worker won't interfere with the docs' development.
  • Is it automatic? No - users have to opt-in to having offline capabilities by clicking a button. This is based on Fred's idea here.

@netlify
Copy link

netlify bot commented Oct 22, 2022

Deploy Preview for astro-docs-2 ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 69909e9
🔍 Latest deploy log https://app.netlify.com/sites/astro-docs-2/deploys/635874475c2b8600094ed56c
😎 Deploy Preview https://deploy-preview-1888--astro-docs-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@sarah11918 sarah11918 added the hacktoberfest-accepted Mark a PR as accepted to contribute towards Hacktoberfest label Oct 23, 2022
@zadeviggers zadeviggers marked this pull request as ready for review October 25, 2022 18:22
@zadeviggers zadeviggers changed the title [DRAFT] Offline support [WIP] Offline support Oct 25, 2022
@zadeviggers zadeviggers changed the title [WIP] Offline support Offline support Oct 25, 2022
@sarah11918 sarah11918 added the site improvement Some thing that improves the website functionality - ask @delucis for help! label Oct 27, 2022
Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @zadeviggers! Thanks so much for exploring this — it’s super cool and sorry we haven’t had time to really dive into reviewing this complex PR.

I’m wondering if you think we could use some existing packages out there to get some similar functionality? This is a lot of code we would need to maintain and debug in the future and it feels like maybe for some of it we could be re-using prior art from other packages.

@zadeviggers
Copy link
Contributor Author

Using external package was actually the first thing I tried. I tried vite-plugin-pwa and several others, but they were all either too complex (e.g. they added a lot of extra pwa features that we don’t want rather than just offline mode, as well as being very hard to configure), or were just straight up incompatible with Astro for various reasons.
In the end, having a custom integration and service worker was the simplest solution.
It did make me realise that since this functionality is hard to get set up in an Astro project, maybe instead of having a custom implementation here, I could extract it all to a new npm package that the docs site could depend on?

@sarah11918
Copy link
Member

Well @zadeviggers, sometimes these PRs just take time, and sometime they don't work out.

We've discussed this a few times now, and we keep coming back to the issue of not wanting to take on the maintenance burden of a PWA. Especially now that we have Astro docs on devdocs.io, we have an offline option for readers with the added advantage of being higher profile and putting us up with a ton of other docs.

So, we're closing this PR, BUT I do think a prominent link somewhere that these docs are available on devdocs.io would be a good idea for people who do want offline docs but don't know about it. Thank you for making sure this issue stayed on our minds, and the thought and attention you've given it. The final decision is that we're content to go with the devdocs.io solution for offline reading.

@sarah11918 sarah11918 closed this Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted Mark a PR as accepted to contribute towards Hacktoberfest site improvement Some thing that improves the website functionality - ask @delucis for help!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants