WIP [erp5_web_renderjs_ui] Replace appcache by a service worker
Fetch usage can be bypassed to do not use service worker when not needed. As appcache has been dropped on Firefox, this change will improve the speed on Firefox. No change is expected on Chrome/Safari. Replace Base_getListFileFromAppcache with Base_getTranslationSourceFileList. Collect a list of files from service worker code. Use cache.add because safari does not support cache.addAll. Don't give request object itself to cache.match. Firefox's Cache Storage does not work properly when VARY contains Accept-Language. Give URL string instead, then cache.match works on both Firefox and Chrome. Stop calling skipWaiting() and clients.claim() for the new service worker. To preserve the consistency of code and data, let the new service worker wait until all tabs and windows of the old version are closed. New client can use the latest cache without waiting for the new service worker to be activated. And once client was associated with a cache, client keeps using the same cache. Fix translation script. Get service worker filename from layout property. Don't hardcode it. Fix service worker. Don't hardcode the special cache name. The name must be different per web site, else if the same service worker code is used by multiple web sites in ERP5 web site module, service worker does not work correctly. Add more comments because service worker is unstable and hard to use safely. If service worker failed to install cache, unregister this service worker explicitly. Update service worker code. Client_id is null when it is the first request, in other words if request is navigate mode. Since major web browsers already implement client_id, if client_is is null, let's use the latest cache and don't get cache_key from CACHE_MAP and erp5js_cache. service worker document may not exist duplicate files by adding language prefix experiment base tag on launcher use relative url with .. to fetch gadgets Drop base tag, because it will probably break all erp5js forks, which hardcode url strings remove all hardcoded precache requirement fetch the wallpaper from the base url remove all clientIds handling Waiting for all clients to be closed before activating the new service worker is not usable, as it will lead to user keeping the old code. Drop the logic for now. Fetch the list of precache url dynamically in order to decouple the worker code from the list of files. Calculate dynamically the list of files from a python script, depending on the web site configuration. Update the service worker as soon as the web site modification date changes. This (I hope) will simplify ERP5 upgrade handling. allow to extend the list of precache urls do not hammer zope during installation erp5_web_renderjs_ui: browser send GMT suffix * reload the page only if there is no notification * delay the sw installation * do not reload after first worker installation * embed the dependency list in the worker code * global are deleted when the worker is stopped, which make the current fetch code less interesting... * automatically handle service worker update and page refresh * ensure that user automatically uses the latest code without manually refreshing the page. * catch worker registration error * catch worker update error erp5_web_renderjs_ui: precache: missing dependencies + json export * use precache manifest * launcher interface is now checked * extract translatable file list
Showing
This diff is collapsed.
Please register or sign in to comment