Skip to content
This repository was archived by the owner on Jan 23, 2021. It is now read-only.
This repository was archived by the owner on Jan 23, 2021. It is now read-only.

MIME type ('text/html') is not executable, and strict MIME type checking is enabled. #180

Description

@brotzky

This is the issue I'm getting

  • Deploy files to to server
  • Service Worker caches all the files
  • Deploy updated files to server
  • Get this error on refresh after deploying updated files: Refused to execute script from 'https:/www.example.com/app.jf813asdfd3t.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

Doing a hard refresh (CMD + SHIFT + R) skips the service worker cache and loads the newly deployed files without any issues. And then doing a regular refresh causes the error to come back.

My sw.js is not being cached and have nginx setup.

Deploying an update and refreshing pulls files from service worker, but they have the incorrect content-type.
screen shot 2016-09-13 at 9 02 54 am

Doing a hard refresh solves the issue
screen shot 2016-09-13 at 9 03 13 am

As you can see form the images, the files are being pulled from the same location, except that the service worker is pulling the incorrect content. When I go into the Chrome Develop Tool network tab and "preview" the content the service worker JS file contains only HTML and the hard reloaded one is actual JS.

I am using React with React Router.
This is my sw-precache webpack config:

new SWPrecacheWebpackPlugin({
  cacheId: 'someSecretString',
  filename: 'sw.js',
  dontCacheBustUrlsMatching: [/./],
  staticFileGlobs: [path.join(__dirname, '../../build/') + '/**/*.{js,html,css,svg}'],
  stripPrefix: path.join(__dirname, '../../build/'),
  maximumFileSizeToCacheInBytes: 4194304,
  navigateFallback: 'index.html',
})

My initial guess is that it's an issue with nginx, but asking if you guys have any other guesses.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions