title: Laravel service worker
body: <p>I have manifest on my site. <br>
  In Laravel application I added on main page code by recommendations google:</p>
  
  <pre><code>@section('js')
  &lt;script&gt;
     if('serviceWorker' in navigator) {
      navigator.serviceWorker
              .register('/sw.js')
              .then(function() { console.log("Service Worker Registered"); });
     }
  &lt;/script&gt;
  @endsection
  </code></pre>
  
  <p>And when I added this code, on main page lost authorization session. That I on main page not authorized, but in other pages authorized. How that? How I can fix this?</p>
  
  <p>Sw.js:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>/*
   *
   *  Air Horner
   *  Copyright 2015 Google Inc. All rights reserved.
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *      https://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License
   *
   */
  
  // Version 0.6.2
  let version = '0.6.2';
  
  self.addEventListener('install', e =&gt; {
    let timeStamp = Date.now();
    e.waitUntil(
      caches.open('airhorner').then(cache =&gt; {
        return cache.addAll([
          `/`,
          `/css/vendor.min.css?timestamp=${timeStamp}`,
          `/css/styles.min.css?timestamp=${timeStamp}`,
          `/js/vendor.min.js?timestamp=${timeStamp}`,
          `/js/scripts.min.js?timestamp=${timeStamp}`,
          `/js/main.js?timestamp=${timeStamp}`,
          `/js/modernizr.min.js?timestamp=${timeStamp}`,
          `/js/cart.js?timestamp=${timeStamp}`,
          `/js/dropzone.js?timestamp=${timeStamp}`,
          `/js/iziToast.min.js?timestamp=${timeStamp}`,
        ])
        .then(() =&gt; self.skipWaiting());
      })
    )
  });
  
  self.addEventListener('activate',  event =&gt; {
    event.waitUntil(self.clients.claim());
  });
  
  self.addEventListener('fetch', event =&gt; {
    event.respondWith(
      caches.match(event.request, {ignoreSearch:true}).then(response =&gt; {
        return response || fetch(event.request);
      })
    );
  });</code></pre>
  </div>
  </div>
  </p>