3

My cache manifest file looks like:

CACHE MANIFEST

calendar.html
scripts/jquery.js
scripts/calendar.js

NETWORK:

https://apis.google.com/js/client.js

My calendar.html looks something like:

<html manifest="calendar.cache">
  <head>
    <script src="scripts/jquery.js" type="text/javascript"></script>
    <script src="scripts/calendar.js" type="text/javascript"></script>
    <script src='https://apis.google.com/js/client.js?onload=checkAuth'></script>
  </head>
  <body>
    <div id="authorize-div" style="display: inline">
      <span>Authorize access to Google Calendar API</span>
      <!--Button for the user to click to initiate auth sequence -->
      <button id="authorize-button">
        Authorize
      </button>
    </div>
    <pre id="output"></pre>
    <script>

    $(document).ready(function(){

        console.log("ready");
    })
    </script>
  </body>
</html>

If I disable the cache everything works fine. However, when the cache is enabled I get an error for the apis.google.com/js/client.js file. The error is jquery.js:5 GET https://apis.google.com/js/client.js?onload=checkAuth&_=1474962265124 net::ERR_FAILED. This is for google chrome browser, but I get a similar error for firefox. What am I missing?

Mfswiggs
  • 307
  • 1
  • 6
  • 16

1 Answers1

2

This is caused due to those parameters which you are passing for client.js ie.?onload=checkAuth

In web whenever you pass any parameter that request is considered unique.So as far as the browser is concerned scripts declared in your manifest aren't the same

https://apis.google.com/js/client.js // script A
https://apis.google.com/js/client.js?onload=checkAuth //script B ≠ script A

But in calendar.cache you have declared only script A as non-cached.So now you can guess changing manifest to below would solve the issue

CACHE MANIFEST
calendar.html
scripts/jquery.js
scripts/calendar.js

NETWORK:
https://apis.google.com/js/client.js?onload=checkAuth

Ofc just removing onload=checkAuth could also work in-case you don't need the callback.Just wipe entire cache and reload to see the magic!

Vinay
  • 7,442
  • 6
  • 25
  • 48