{"id":3514,"date":"2026-11-22T10:13:10","date_gmt":"2026-11-22T04:43:10","guid":{"rendered":"https:\/\/larapush.com\/blog\/?p=3514"},"modified":"2026-11-22T10:13:10","modified_gmt":"2026-11-22T04:43:10","slug":"changing-service-worker-file-web-push","status":"publish","type":"post","link":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/","title":{"rendered":"What Happens If You Change or Replace Your Service Worker File?"},"content":{"rendered":"\n<p><strong>If you change the code inside your web push service worker file and keep the same URL and scope, subscribers stay subscribed. The browser installs the new version and activates it once old tabs close. Subscribers are lost only when you unregister the worker, change its scope, or change your VAPID keys.<\/strong><\/p>\n\n\n\n<p>This question usually comes up at an awkward moment: a developer wants to rename sw.js, merge two workers, or switch push tools. The safe answer depends on what exactly changes. Editing the file is routine. Renaming it, moving it or deleting it is where push subscriptions get hurt. Below I break down each case, what the browser does, and how I&#8217;d make the change safely.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_63 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#What_happens_when_you_change_your_service_worker_file_for_web_push\" title=\"What happens when you change your service worker file for web push?\">What happens when you change your service worker file for web push?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#Does_changing_the_service_worker_unsubscribe_your_push_subscribers\" title=\"Does changing the service worker unsubscribe your push subscribers?\">Does changing the service worker unsubscribe your push subscribers?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#What_does_%E2%80%9Cwaiting_to_activate%E2%80%9D_mean_after_an_update\" title=\"What does &#8220;waiting to activate&#8221; mean after an update?\">What does &#8220;waiting to activate&#8221; mean after an update?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#Should_you_rename_your_service_worker_file\" title=\"Should you rename your service worker file?\">Should you rename your service worker file?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#What_if_you_move_the_service_worker_to_a_different_folder\" title=\"What if you move the service worker to a different folder?\">What if you move the service worker to a different folder?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#What_happens_if_you_change_VAPID_keys_or_push_providers\" title=\"What happens if you change VAPID keys or push providers?\">What happens if you change VAPID keys or push providers?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#How_do_you_change_a_push_service_worker_safely\" title=\"How do you change a push service worker safely?\">How do you change a push service worker safely?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#How_do_you_check_which_service_worker_version_is_live\" title=\"How do you check which service worker version is live?\">How do you check which service worker version is live?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#Where_LaraPush_fits\" title=\"Where LaraPush fits\">Where LaraPush fits<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#Frequently_asked_questions\" title=\"Frequently asked questions\">Frequently asked questions<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_happens_when_you_change_your_service_worker_file_for_web_push\"><\/span>What happens when you change your service worker file for web push?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>When you change a service worker file at the same URL, the browser treats it as an update, not a new worker. It downloads the file, compares it byte by byte with the installed copy, and installs the new version if anything differs.<\/p>\n\n\n\n<p>The update check runs on its own schedule. According to web.dev&#8217;s guide to the <a href=\"https:\/\/web.dev\/articles\/service-worker-lifecycle\" target=\"_blank\" rel=\"noreferrer noopener\">service worker lifecycle<\/a>, an update is triggered by a navigation to an in-scope page, or by functional events such as push, unless the browser already checked in the previous 24 hours. Most browsers, including Chrome 68 and later, ignore HTTP caching headers for that check by default.<\/p>\n\n\n\n<p>So for a push-only worker, the key point is this. Your push subscription belongs to the service worker registration, not to one version of the file. As a result, editing the code inside sw.js doesn&#8217;t touch the subscription. The same endpoint keeps working after the new version takes over.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Does_changing_the_service_worker_unsubscribe_your_push_subscribers\"><\/span>Does changing the service worker unsubscribe your push subscribers?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>No, a normal code change doesn&#8217;t unsubscribe anyone. However, four specific changes can break subscriptions or stop notifications from showing.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Change<\/th><th>What happens to push subscribers<\/th><th>Risk<\/th><\/tr><\/thead><tbody><tr><td>Edit code in the same sw.js<\/td><td>Same registration, same subscription; new code runs after activation<\/td><td>Low<\/td><\/tr><tr><td>Rename the file (sw.js to sw-v2.js) at the same scope<\/td><td>Registration updates to the new script; existing pages may still register the old URL<\/td><td>Medium<\/td><\/tr><tr><td>Move the file to a different folder (new scope)<\/td><td>A new registration is created; subscribers on the old scope don&#8217;t move across<\/td><td>High<\/td><\/tr><tr><td>Unregister the worker or delete the file<\/td><td>Push API spec says the subscription must be deactivated<\/td><td>High<\/td><\/tr><tr><td>Change VAPID keys<\/td><td>Existing subscriptions were made with the old public key, so sends with the new key fail<\/td><td>High<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>The unregister row comes straight from the W3C <a href=\"https:\/\/www.w3.org\/TR\/push-api\/\" target=\"_blank\" rel=\"noreferrer noopener\">Push API specification<\/a>, which says a push subscription is deactivated when its service worker registration is unregistered. That&#8217;s why &#8220;just clean up the old worker&#8221; can quietly wipe out a list.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_does_%E2%80%9Cwaiting_to_activate%E2%80%9D_mean_after_an_update\"><\/span>What does &#8220;waiting to activate&#8221; mean after an update?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>It means the new version installed but the old one still controls open tabs. By default, a new service worker waits until every tab using the old version is closed. Only then does it activate.<\/p>\n\n\n\n<p>For push, that wait is usually harmless. The old version keeps handling push events, so notifications still appear. However, if your fix is urgent, such as a broken notificationclick handler, you can call <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/ServiceWorkerGlobalScope\/skipWaiting\" target=\"_blank\" rel=\"noreferrer noopener\">skipWaiting()<\/a> during install. That makes the new worker activate straight away.<\/p>\n\n\n\n<p>There&#8217;s one caution. If your worker also caches pages, skipWaiting() means the new version may control pages loaded by the old one. A push-only worker doesn&#8217;t have that problem, because it doesn&#8217;t serve page requests.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Should_you_rename_your_service_worker_file\"><\/span>Should you rename your service worker file?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>No, avoid renaming it unless you must. The web.dev lifecycle guide says plainly: avoid changing the URL of your service worker script, and update the script at its existing location instead.<\/p>\n\n\n\n<p>The reason is caching. Your pages call navigator.serviceWorker.register() with a specific URL. If a cached page still references sw.js while new pages reference sw-v2.js, the two can fight over the same scope. In practice, that leads to flaky updates and &#8220;it works on my machine&#8221; bugs.<\/p>\n\n\n\n<p>If you really need a new file name, keep the old URL alive for a while. For example, keep sw.js as a tiny file that imports the new code with importScripts(). That way, every page and every old registration still points to a working worker.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_if_you_move_the_service_worker_to_a_different_folder\"><\/span>What if you move the service worker to a different folder?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Moving the file changes its default scope, and a different scope means a different registration. Subscribers who signed up under the old registration don&#8217;t transfer to the new one automatically.<\/p>\n\n\n\n<p>That&#8217;s the main reason I recommend serving a push worker from the site root. My guide to setting up a <a href=\"https:\/\/larapush.com\/blog\/service-worker-for-web-push\/\">service worker for web push<\/a> explains scope and the Service-Worker-Allowed header. If you&#8217;ve already moved it, keep the old file in place until you&#8217;ve confirmed the new registration works. Don&#8217;t unregister the old one while it still holds subscribers you care about.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_happens_if_you_change_VAPID_keys_or_push_providers\"><\/span>What happens if you change VAPID keys or push providers?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Changing VAPID keys breaks existing subscriptions. Each subscription was created with your old public key, so push services reject messages signed with a new private key. My explainer on <a href=\"https:\/\/larapush.com\/blog\/vapid-keys-web-push\/\">what VAPID keys are<\/a> covers why the pair must stay stable.<\/p>\n\n\n\n<p>Switching push providers is similar. The new tool usually ships its own service worker and its own keys. So the old subscriptions don&#8217;t carry over by themselves, even if the file name is the same. Before switching, read what happens when a <a href=\"https:\/\/larapush.com\/blog\/push-provider-shutdown-subscribers\/\">push provider shuts down or you leave<\/a>, and plan to re-prompt visitors where needed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_do_you_change_a_push_service_worker_safely\"><\/span>How do you change a push service worker safely?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Treat it as a small release. These steps keep subscribers and notifications working.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Keep the same file name and path, and edit the code in place.<\/li>\n\n\n\n<li>Back up the current file before you change anything.<\/li>\n\n\n\n<li>Test the new version on a staging site or in a separate browser profile.<\/li>\n\n\n\n<li>Check Application > Service workers in Chrome DevTools to confirm the new version installs.<\/li>\n\n\n\n<li>Send a test push to your own subscription, then click it.<\/li>\n\n\n\n<li>Deploy, and confirm the server returns the new file without a long cache lifetime.<\/li>\n\n\n\n<li>Watch delivery and click counts for a day before you remove any old code paths.<\/li>\n<\/ol>\n\n\n\n<p>If something goes wrong, my guide to <a href=\"https:\/\/larapush.com\/blog\/debug-web-push-in-chrome-devtools\/\">debug web push in Chrome DevTools<\/a> walks through each panel. Also, never run two push workers on the same scope. One will replace the other.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_do_you_check_which_service_worker_version_is_live\"><\/span>How do you check which service worker version is live?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Open Chrome DevTools, go to Application > Service workers, and look at the source file and status. The status line shows which version is active and whether another is waiting.<\/p>\n\n\n\n<p>You can also add a version constant at the top of sw.js and log it on activate. That makes it easy to confirm in the Console which build is running. Finally, check chrome:\/\/serviceworker-internals if you suspect an old registration is still hanging around.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Where_LaraPush_fits\"><\/span>Where LaraPush fits<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>LaraPush is a self-hosted web push panel that you install on your own VPS. It provides the service worker and JavaScript for your site, or you can use the free WordPress plugin. Since the panel runs on a server you control, you can check the sending side yourself when a worker change seems to break delivery.<\/p>\n\n\n\n<p>The trade-offs: you run and maintain the server, a licence covers one server, and there&#8217;s no free plan. Prices start from $499 one-time; check the <a href=\"https:\/\/larapush.com\/pricing\/\">pricing page<\/a> for the current price. Setup steps are in the <a href=\"https:\/\/larapush.com\/guide\/\">LaraPush guide<\/a>, and the <a href=\"https:\/\/larapush.com\/features\/\">features page<\/a> lists what&#8217;s included. For context on the wider market, see my <a href=\"https:\/\/larapush.com\/blog\/best-push-notification-services-and-tools\/\">comparison of push notification services<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Frequently_asked_questions\"><\/span>Frequently asked questions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1763801600000\"><strong class=\"schema-faq-question\">Will updating sw.js unsubscribe my web push subscribers?<\/strong> <p class=\"schema-faq-answer\">No. If you keep the same URL and scope, the browser treats the change as an update. The push subscription belongs to the registration, so it keeps working. The new code takes over once old tabs close, or immediately if you call skipWaiting().<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1763801601111\"><strong class=\"schema-faq-question\">How often does the browser check for a new service worker version?<\/strong> <p class=\"schema-faq-answer\">It checks when someone navigates to an in-scope page, and on events such as push, unless it already checked in the previous 24 hours. Most browsers, including Chrome 68 and later, ignore caching headers for this check by default.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1763801602222\"><strong class=\"schema-faq-question\">Can I rename my service worker file without losing subscribers?<\/strong> <p class=\"schema-faq-answer\">It&#8217;s possible but risky. Cached pages may still register the old URL while new pages register the new one. If you must rename, keep the old URL serving a small file that imports the new code, so every registration still finds a working worker.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1763801603333\"><strong class=\"schema-faq-question\">Does unregistering a service worker delete push subscriptions?<\/strong> <p class=\"schema-faq-answer\">Yes. The W3C Push API specification says a push subscription is deactivated when its service worker registration is unregistered. Only unregister a push worker when you&#8217;re sure you no longer need the subscribers attached to it.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1763801604444\"><strong class=\"schema-faq-question\">Do I need to change my service worker when I change push providers?<\/strong> <p class=\"schema-faq-answer\">Usually, yes. A new provider normally brings its own service worker and VAPID keys. Old subscriptions were made with the previous keys, so they don&#8217;t carry over automatically. Plan the switch, remove the old worker cleanly and re-prompt visitors.<\/p> <\/div><\/div>\n","protected":false},"excerpt":{"rendered":"Changing your web push service worker file: what keeps subscribers safe, what breaks them, and how to update sw.js without losing anyone.","protected":false},"author":7,"featured_media":3519,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","csco_display_header_overlay":false,"csco_singular_sidebar":"","csco_page_header_type":""},"categories":[76],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What Happens If You Change or Replace Your Service Worker File?<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What Happens If You Change or Replace Your Service Worker File?\" \/>\n<meta property=\"og:description\" content=\"Changing your web push service worker file: what keeps subscribers safe, what breaks them, and how to update sw.js without losing anyone.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/\" \/>\n<meta property=\"og:site_name\" content=\"LaraPush Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-22T04:43:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2026\/11\/changing-service-worker-file-web-push.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"675\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Ritesh Das\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ritesh Das\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/\"},\"author\":{\"name\":\"Ritesh Das\",\"@id\":\"https:\/\/larapush.com\/blog\/#\/schema\/person\/4f23894f98426ea3a6bd617e59f03bbd\"},\"headline\":\"What Happens If You Change or Replace Your Service Worker File?\",\"datePublished\":\"2026-11-22T04:43:10+00:00\",\"dateModified\":\"2026-11-22T04:43:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/\"},\"wordCount\":1559,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/larapush.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2026\/11\/changing-service-worker-file-web-push.jpg\",\"articleSection\":[\"FAQs\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#respond\"]}]},{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/\",\"url\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/\",\"name\":\"What Happens If You Change or Replace Your Service Worker File?\",\"isPartOf\":{\"@id\":\"https:\/\/larapush.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2026\/11\/changing-service-worker-file-web-push.jpg\",\"datePublished\":\"2026-11-22T04:43:10+00:00\",\"dateModified\":\"2026-11-22T04:43:10+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#breadcrumb\"},\"mainEntity\":[{\"@id\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801600000\"},{\"@id\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801601111\"},{\"@id\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801602222\"},{\"@id\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801603333\"},{\"@id\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801604444\"}],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#primaryimage\",\"url\":\"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2026\/11\/changing-service-worker-file-web-push.jpg\",\"contentUrl\":\"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2026\/11\/changing-service-worker-file-web-push.jpg\",\"width\":1200,\"height\":675,\"caption\":\"Illustration of what happens when you change a service worker file for web push, a gear file swapped with a refresh arrow and bell\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/larapush.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What Happens If You Change or Replace Your Service Worker File?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/larapush.com\/blog\/#website\",\"url\":\"https:\/\/larapush.com\/blog\/\",\"name\":\"LaraPush Blog\",\"description\":\"Stay Ahead, Stay Notified with LaraPush!\",\"publisher\":{\"@id\":\"https:\/\/larapush.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/larapush.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/larapush.com\/blog\/#organization\",\"name\":\"LaraPush\",\"url\":\"https:\/\/larapush.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/larapush.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2022\/05\/LARAPUSH.png\",\"contentUrl\":\"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2022\/05\/LARAPUSH.png\",\"width\":280,\"height\":60,\"caption\":\"LaraPush\"},\"image\":{\"@id\":\"https:\/\/larapush.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/larapush.com\/blog\/#\/schema\/person\/4f23894f98426ea3a6bd617e59f03bbd\",\"name\":\"Ritesh Das\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/larapush.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1bd7bb0ba68e36b218587b72e89e511f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/1bd7bb0ba68e36b218587b72e89e511f?s=96&d=mm&r=g\",\"caption\":\"Ritesh Das\"},\"url\":\"https:\/\/larapush.com\/blog\/author\/riteshdas\/\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801600000\",\"position\":1,\"url\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801600000\",\"name\":\"Will updating sw.js unsubscribe my web push subscribers?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"No. If you keep the same URL and scope, the browser treats the change as an update. The push subscription belongs to the registration, so it keeps working. The new code takes over once old tabs close, or immediately if you call skipWaiting().\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801601111\",\"position\":2,\"url\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801601111\",\"name\":\"How often does the browser check for a new service worker version?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"It checks when someone navigates to an in-scope page, and on events such as push, unless it already checked in the previous 24 hours. Most browsers, including Chrome 68 and later, ignore caching headers for this check by default.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801602222\",\"position\":3,\"url\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801602222\",\"name\":\"Can I rename my service worker file without losing subscribers?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"It's possible but risky. Cached pages may still register the old URL while new pages register the new one. If you must rename, keep the old URL serving a small file that imports the new code, so every registration still finds a working worker.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801603333\",\"position\":4,\"url\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801603333\",\"name\":\"Does unregistering a service worker delete push subscriptions?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Yes. The W3C Push API specification says a push subscription is deactivated when its service worker registration is unregistered. Only unregister a push worker when you're sure you no longer need the subscribers attached to it.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801604444\",\"position\":5,\"url\":\"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801604444\",\"name\":\"Do I need to change my service worker when I change push providers?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Usually, yes. A new provider normally brings its own service worker and VAPID keys. Old subscriptions were made with the previous keys, so they don't carry over automatically. Plan the switch, remove the old worker cleanly and re-prompt visitors.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What Happens If You Change or Replace Your Service Worker File?","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/","og_locale":"en_US","og_type":"article","og_title":"What Happens If You Change or Replace Your Service Worker File?","og_description":"Changing your web push service worker file: what keeps subscribers safe, what breaks them, and how to update sw.js without losing anyone.","og_url":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/","og_site_name":"LaraPush Blog","article_published_time":"2026-11-22T04:43:10+00:00","og_image":[{"width":1200,"height":675,"url":"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2026\/11\/changing-service-worker-file-web-push.jpg","type":"image\/jpeg"}],"author":"Ritesh Das","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Ritesh Das","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#article","isPartOf":{"@id":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/"},"author":{"name":"Ritesh Das","@id":"https:\/\/larapush.com\/blog\/#\/schema\/person\/4f23894f98426ea3a6bd617e59f03bbd"},"headline":"What Happens If You Change or Replace Your Service Worker File?","datePublished":"2026-11-22T04:43:10+00:00","dateModified":"2026-11-22T04:43:10+00:00","mainEntityOfPage":{"@id":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/"},"wordCount":1559,"commentCount":0,"publisher":{"@id":"https:\/\/larapush.com\/blog\/#organization"},"image":{"@id":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#primaryimage"},"thumbnailUrl":"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2026\/11\/changing-service-worker-file-web-push.jpg","articleSection":["FAQs"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#respond"]}]},{"@type":["WebPage","FAQPage"],"@id":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/","url":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/","name":"What Happens If You Change or Replace Your Service Worker File?","isPartOf":{"@id":"https:\/\/larapush.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#primaryimage"},"image":{"@id":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#primaryimage"},"thumbnailUrl":"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2026\/11\/changing-service-worker-file-web-push.jpg","datePublished":"2026-11-22T04:43:10+00:00","dateModified":"2026-11-22T04:43:10+00:00","breadcrumb":{"@id":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#breadcrumb"},"mainEntity":[{"@id":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801600000"},{"@id":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801601111"},{"@id":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801602222"},{"@id":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801603333"},{"@id":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801604444"}],"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#primaryimage","url":"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2026\/11\/changing-service-worker-file-web-push.jpg","contentUrl":"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2026\/11\/changing-service-worker-file-web-push.jpg","width":1200,"height":675,"caption":"Illustration of what happens when you change a service worker file for web push, a gear file swapped with a refresh arrow and bell"},{"@type":"BreadcrumbList","@id":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/larapush.com\/blog\/"},{"@type":"ListItem","position":2,"name":"What Happens If You Change or Replace Your Service Worker File?"}]},{"@type":"WebSite","@id":"https:\/\/larapush.com\/blog\/#website","url":"https:\/\/larapush.com\/blog\/","name":"LaraPush Blog","description":"Stay Ahead, Stay Notified with LaraPush!","publisher":{"@id":"https:\/\/larapush.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/larapush.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/larapush.com\/blog\/#organization","name":"LaraPush","url":"https:\/\/larapush.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/larapush.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2022\/05\/LARAPUSH.png","contentUrl":"https:\/\/larapush.com\/blog\/wp-content\/uploads\/2022\/05\/LARAPUSH.png","width":280,"height":60,"caption":"LaraPush"},"image":{"@id":"https:\/\/larapush.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/larapush.com\/blog\/#\/schema\/person\/4f23894f98426ea3a6bd617e59f03bbd","name":"Ritesh Das","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/larapush.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/1bd7bb0ba68e36b218587b72e89e511f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1bd7bb0ba68e36b218587b72e89e511f?s=96&d=mm&r=g","caption":"Ritesh Das"},"url":"https:\/\/larapush.com\/blog\/author\/riteshdas\/"},{"@type":"Question","@id":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801600000","position":1,"url":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801600000","name":"Will updating sw.js unsubscribe my web push subscribers?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"No. If you keep the same URL and scope, the browser treats the change as an update. The push subscription belongs to the registration, so it keeps working. The new code takes over once old tabs close, or immediately if you call skipWaiting().","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801601111","position":2,"url":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801601111","name":"How often does the browser check for a new service worker version?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"It checks when someone navigates to an in-scope page, and on events such as push, unless it already checked in the previous 24 hours. Most browsers, including Chrome 68 and later, ignore caching headers for this check by default.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801602222","position":3,"url":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801602222","name":"Can I rename my service worker file without losing subscribers?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"It's possible but risky. Cached pages may still register the old URL while new pages register the new one. If you must rename, keep the old URL serving a small file that imports the new code, so every registration still finds a working worker.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801603333","position":4,"url":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801603333","name":"Does unregistering a service worker delete push subscriptions?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Yes. The W3C Push API specification says a push subscription is deactivated when its service worker registration is unregistered. Only unregister a push worker when you're sure you no longer need the subscribers attached to it.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801604444","position":5,"url":"https:\/\/larapush.com\/blog\/changing-service-worker-file-web-push\/#faq-question-1763801604444","name":"Do I need to change my service worker when I change push providers?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Usually, yes. A new provider normally brings its own service worker and VAPID keys. Old subscriptions were made with the previous keys, so they don't carry over automatically. Plan the switch, remove the old worker cleanly and re-prompt visitors.","inLanguage":"en-US"},"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/posts\/3514"}],"collection":[{"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/comments?post=3514"}],"version-history":[{"count":1,"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/posts\/3514\/revisions"}],"predecessor-version":[{"id":3520,"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/posts\/3514\/revisions\/3520"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/media\/3519"}],"wp:attachment":[{"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/media?parent=3514"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/categories?post=3514"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/larapush.com\/blog\/wp-json\/wp\/v2\/tags?post=3514"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}