{"result":{"depiction_url":null,"edges":{"subject":{"objects":[{"created":"2026-09-30T09:11:24Z","object_id":{"id":2555,"is_a":["categorization","keyword","keyword_information_type"],"name":"zotonic_topic_reference","title":"Reference","uri":"https:\/\/zotonic.com\/id\/2555"},"seq":1},{"created":"2026-09-30T09:11:24Z","object_id":{"id":2563,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_frontend_developer","title":"Frontend developer","uri":"https:\/\/zotonic.com\/id\/2563"},"seq":2},{"created":"2026-09-30T09:11:24Z","object_id":{"id":2625,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_model","title":"Model","uri":"https:\/\/zotonic.com\/id\/2625"},"seq":3},{"created":"2026-09-30T09:11:24Z","object_id":{"id":2673,"is_a":["categorization","keyword","keyword_technology"],"name":"zotonic_topic_javascript","title":"JavaScript","uri":"https:\/\/zotonic.com\/id\/2673"},"seq":4},{"created":"2026-09-30T09:11:24Z","object_id":{"id":2718,"is_a":["categorization","keyword","keyword_technology"],"name":"zotonic_topic_cotonic","title":"Cotonic","uri":"https:\/\/zotonic.com\/id\/2718"},"seq":5},{"created":"2026-09-30T09:11:24Z","object_id":{"id":2720,"is_a":["categorization","keyword","keyword_technology"],"name":"zotonic_topic_service_workers","title":"Service Workers","uri":"https:\/\/zotonic.com\/id\/2720"},"seq":6}],"predicate":{"id":308,"is_a":["meta","predicate"],"name":"subject","title":{"_type":"trans","tr":{"en":"Keyword"}},"uri":"http:\/\/purl.org\/dc\/elements\/1.1\/subject"}}},"id":2740,"is_a":["text","documentation","reference","cotonic_reference","cotonic_model"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/2740"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_cotonic_model_serviceworker","page_url":{"en":"https:\/\/zotonic.com\/cotonic\/models\/serviceworker","x-default":"https:\/\/zotonic.com\/cotonic\/models\/serviceworker"},"preview_url":null,"resource":{"version":15,"pivot_location_lat":null,"title":"model\/serviceWorker","is_authoritative":true,"body":"<a name=\"model.serviceWorker\"><\/a><h3>model\/serviceWorker<\/h3>\n\n            <p>\n            The serviceWorker model makes it possible to communicate with other tabs\n            from the same site. This makes it possible to communicate important state\n            to all tabs.\n            <\/p>\n\n            <div class=\"note\">\n                <h4>A Note on Security<\/h4><p>\n                The serviceWorker needs https to work correctly. The <i>Chrome<\/i> browser\n                does not accept self-signed certificates for running serviceWorkers.\n                Either run from localhost, use a real certificate, or follow the instructions\n                <a rel=\"nofollow noopener noreferrer\" href=\"https:\/\/deanhume.com\/testing-service-workers-locally-with-self-signed-certificates\/\" target=\"_blank\">on this page by Dean Hume<\/a>.\n                <\/p>\n\n                <p>\n                Safari and Firefox accept self-signed certificates for\n                running the serviceWorker.\n                <\/p>\n            <\/div>\n\n            <a name=\"model.serviceWorker.post.broadcast.channel\"><\/a><h4>post\/broadcast\/+channel<\/h4><p>\n            Broadcast the message on <tt>channel<\/tt>. The message can be received\n            via the <tt>&quot;model\/serviceWorker\/event\/+channel<\/tt> topic. This works\n            across all open tabs.\n            <\/p>\n            <pre>\n\/\/ Publish from a worker\nself.publish(&quot;model\/serviceWorker\/post\/broadcast\/background&quot;,\n             {hue: &quot;blue&quot;, brightness: 45});\n            <\/pre>\n\n            <a name=\"model.serviceWorker.event.broadcast.channel\"><\/a><h4>event\/broadcast\/+channel<\/h4><p>\n            Subscribe to the broadcast <tt>channel<\/tt> of the serviceWorker. Messages\n            posted from other tabs or workers, including messages sent by the publisher\n            will be received.\n            <\/p>\n            <pre>\n\/\/ Subscribe on a page\ncotonic.broker.subscribe(&quot;model\/serviceWorker\/event\/broadcast\/background&quot;,\n    function(m) {\n        console.log(&quot;Setting background to&quot;, m.payload);\n        setBackground(m.payload);\n    })<\/pre>\n\n            <a name=\"model.serviceWorker.event.ping\"><\/a><h4>event\/ping<\/h4><p>\n            When the serviceWorker model is enabled it publishes a retained <tt>pong<\/tt>\n            message on this topic. This makes it possible to check if the model is enabled.\n            <\/p>\n            <pre>\n\/\/ Subscribe on a page\ncotonic.broker.subscribe(&quot;model\/serviceWorker\/event\/ping&quot;,\n    function() {\n        console.log(&quot;the serviceWorker model is enabled&quot;)\n   });<\/pre>\n\n            <a name=\"model.serviceWorker.config\"><\/a><h4><em>Configuration<\/em><\/h4><p>\n            The service worker model has two configuration options.\n            <\/p>\n            <dl>\n                <dt><tt>start_service_worker<\/tt><\/dt>\n                <dd>When set to <tt>false<\/tt>, the service worker will not start.\n                    <br \/><strong>default<\/strong> <tt>true<\/tt><\/dd>\n                <dt><tt>service_worker_src<\/tt><\/dt>\n                <dd>The url of the service worker which should be started.\n                    <br \/><strong>default<\/strong>\n                    <tt>\/cotonic-service-worker.js<\/tt><\/dd>\n            <\/dl>\n\n            <pre>\n&lt;script&gt;\n    window.cotonic = window.cotonic || {};\n    window.cotonic.config = {\n        start_service_worker: true,\n        service_worker_src: &quot;\/cotonic-service-worker.js&quot;\n    };\n&lt;\/script&gt;\n&lt;script src=&quot;cotonic.js&quot;&gt;&lt;\/script&gt;\n\n<\/pre>\n\n\n            <!-- localStorage model -->\n\n            ","slug":"model-serviceworker","is_protected":false,"visible_for":0,"tz":"UTC","language":["en"],"doc_source_hash":"99dc25cd73a60a67004273fd6a2af6955ae3316673fa5a7d9899892fe5108388","is_featured":false,"content_group_id":{"id":2551,"is_a":["meta","content_group"],"name":"content_group_imported_docs","title":"Imported documentation","uri":"https:\/\/zotonic.com\/id\/content_group_imported_docs"},"category_id":{"id":2723,"is_a":["meta","category"],"name":"cotonic_model","title":"Cotonic models","uri":"https:\/\/zotonic.com\/id\/cotonic_model"},"doc_source_path":"index.html","publication_start":"2026-09-30T09:11:23Z","page_path":"\/cotonic\/models\/serviceworker","github_url":"https:\/\/github.com\/cotonic\/cotonic\/blob\/master\/index.html","pivot_location_lng":null,"doc_source_kind":"cotonic","name":"doc_cotonic_model_serviceworker","is_unfindable":false,"is_published":true,"pivot_geocode":null,"created":"2026-09-30T09:11:23Z","uri":null,"doc_source_anchor":"model.serviceWorker","doc_status":"current","is_dependent":false,"publication_end":"9999-06-01T00:00:00Z","modifier_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"privacy":0,"doc_source_commit":"f88cc928b997d10f7f19e6bd0ede80e1c8c619bc","creator_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"modified":"2026-09-30T09:57:32Z","title_slug":"model-serviceworker"},"uri":"https:\/\/zotonic.com\/id\/2740","uri_template":"https:\/\/zotonic.com\/id\/:id","websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/2740"}},"status":"ok"}