Search code examples
iossafaribrowser-cacheservice-workerprogressive-web-apps

PWA: Aggressive caching in iOS 12 Safari


I'm currently debugging my PWA's QR scanner that uses the fabulous library Instascan. It's working perfectly everywhere but iOS, and I'm trying to figure out why. Unfortunately my attempts are halted by Safari's aggressive caching. Safari just doesn't download my new js files. I'm caching these files using a service worker.

What I've tried:

  • Reload the page
  • Open a PWA version of the page
  • Append a version number at the end of the script link (file.js?v=2)
  • Completely close Safari
  • Go to Settings > Safari > Delete history and browsing data
  • Go to Settings > Safari > Advanced > Website data > Delete all website data

Is there any way to ensure that Safari downloads the files when they are changed? My server runs on plain old ASP.NET. I've disabled bundling and minification for the development process, so each file is added with a script tag.


Solution

  • Appending ?v=<random code> to your included js file paths works perfectly. If your bundling is off in ASP.NET, these version numbers are removed. Turns out bundling via ASP.NET already adds random version numbers.

    This question is solved for me.