wordpress-playground icon indicating copy to clipboard operation
wordpress-playground copied to clipboard

Offline mode (PWA)

Open danielbachhuber opened this issue 2 years ago • 12 comments

Network access on contributor days is always problematic.

Once we have something like https://github.com/WordPress/wordpress-playground/issues/104, it would be helpful to have offline support for WordPress Playground. This way, a new contributor could download WordPress Playground once and then be able to use it for the rest of the day.

danielbachhuber avatar Feb 13 '23 23:02 danielbachhuber

If WordPress Playground was a Progressive Web App, it could be:

  • Used on a phone
  • Used for offline apps in general (like notes, cc @ellatrix)
  • Handy as a development environment
  • Downloaded once and used for the rest of the day (handy for Contributor Days on WordCamps where network access is always a problem)

Technically, this would require downloading all the WordPress assets that are currently now hosted on the server. Doing it in the background in idle time after the initial paint should be fine.

adamziel avatar Feb 14 '23 14:02 adamziel

@adamziel I will explore this one and see if I can make any progress on it.

bgrgicak avatar Mar 01 '24 05:03 bgrgicak

I started by adding the Vite PWA plugin and configuring it. The next step is to enable offline support and ensure it works in development and production.

bgrgicak avatar Mar 05 '24 20:03 bgrgicak

Playground loads only a part of WordPress on the first load. Other files are loaded as needed, we will need to find a way to preload all files for full offline support.

bgrgicak avatar Mar 07 '24 08:03 bgrgicak

The offline mode mostly works when we shipping a full, zipped WordPress release. That's what the PR previewer does, e.g. try previewing this PR. We could add a separate offline mode very easily just by using that full zip bundle and caching it in the Service Worker.

adamziel avatar Apr 27 '24 08:04 adamziel

After some discussion with @WordPress/playground-maintainers we create a list of tasks that should add offline and PWA support:

bgrgicak avatar Jun 05 '24 11:06 bgrgicak

Should Playground use browser storage and support networking as the default option when installed?

If yes, it would be great for us to add a site switcher because we can't modify the url.

bgrgicak avatar Jun 06 '24 04:06 bgrgicak

Should Playground use browser storage and support networking as the default option when installed?

It would be handy, yes, but it's not a blocker.

adamziel avatar Jun 12 '24 22:06 adamziel

Flush cache when Playground updates

I wasn't able to get to this today but plan to look at this tomorrow if you don't tackle it first, @bgrgicak.

brandonpayton avatar Jun 19 '24 01:06 brandonpayton

@adamziel has a PR for CLI offline support https://github.com/WordPress/wordpress-playground/pull/1523

bgrgicak avatar Jun 19 '24 05:06 bgrgicak

In a future iteration of offline support, we could add a background check to see if there were any updates to Playground and update the cache with the latest version of Playground.

Today this will work on reload, but mobile and desktop apps aren't usually reloaded.

bgrgicak avatar Jun 27 '24 05:06 bgrgicak

I got offline support to work in the browser. Here is a list of all open PR that are required to make it work.

  • Download all WordPress assets on boot #1532
  • Generate a list of assets to cache for offline support #1573
  • Set service worker startup options with messages instead of query strings #1574
  • Cache Playground assets to enable offline support #1535

bgrgicak avatar Jul 04 '24 12:07 bgrgicak

Please share any future comments in this PR

bgrgicak avatar Jul 12 '24 04:07 bgrgicak