• Romain Courteaud's avatar
    WIP [erp5_web_renderjs_ui] Replace appcache by a service worker · 20c38a07
    Romain Courteaud authored
    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.
    
    [erp5_web_renderjs_ui] Replace Base_getListFileFromAppcache with Base_getTranslationSourceFileList.
    
    Collect a list of files from service worker code.
    
    [erp5_web_renderjs_ui] Fix rjs_gadget_erp5_serviceworker.js. Use cache.add because safari does not support cache.addAll.
    
    [erp5_web_renderjs_ui] Fix rjs_gadget_erp5_serviceworker.js to fix Firefox Cache Storage problem.
    
    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.
    
    [erp5_web_renderjs_ui] 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.
    
    [erp5_web_renderjs_ui] 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.
    
    [erp5_web_renderjs_ui] Fix translation script. Get service worker filename from layout property. Don't hardcode it.
    
    [erp5_web_renderjs_ui] 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.
    
    [erp5_web_renderjs_ui] Add more comments because service worker is unstable and hard to use safely.
    
    [erp5_web_renderjs_ui] If service worker failed to install cache, unregister this service worker explicitly.
    
    [erp5_web_renderjs_ui] Clean up service worker code. Remove many `if`.
    
    [erp5_web_renderjs_ui] Update service worker code. Use lower case for non-global variables.
    
    [erp5_web_renderjs_ui] 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.
    20c38a07
Base_getTranslationSourceFileList.xml 2.23 KB