Spomky-Labs / phpwa-demo

Demonstration for the PHPWA Bundle
0 stars 1 forks source link

update pwa.yaml to reflect 1.1.x changes #15

Open tacman opened 3 months ago

tacman commented 3 months ago

The pwa.yaml file should be updated to reflect the changes in 1.1.x:

Something like this:

        workbox:
            # https://pwa.spomky-labs.com/the-service-worker/workbox/warm-caching-1
            resource_caches:
                  - cache_name: page_cache
                    match_callback: 'regex: |/$|'
                    strategy: 'StaleWhileRevalidate'
                    broadcast: true
                    broadcast_headers:
                        - 'X-App-Cache'
                    preload_urls:
                    - 'app_homepage'
                  - cache_name: pages
                    match_callback: 'regex: |/api/.*$|'
#                    regex: "/api"
                    strategy: CacheFirst
                    broadcast: true
                    broadcast_headers:
                        - 'X-App-Cache'
            offline_fallback:
                page: 'app_homepage'
            background_sync:
                - queue_name: 'items'
                  match_callback: 'regex: {/items/.*$}'
                  broadcast_channel: 'items-sync'
                - queue_name: 'add'
                  match_callback: 'regex: |/add|'
                  method: POST
                  broadcast_channel: 'add-item'

I used pipes and brackets in the regex as I find it easier to read than

'regex: \/articles\/.*$'
'regex: {/articles/.*$}'