我正在开发我的第一个小型create-react-app程序。我希望它能脱机工作,文档说它应该。当我离线运行生产版本时,我得到一条消息
GET http://localhost:3001/static/css/main.6a923b45.css net::ERR_INTERNET_DISCONNECTED
localhost/:1 GET http://localhost:3001/static/js/main.77163466.js net::ERR_INTERNET_DISCONNECTED
An unknown error occurred when fetching the script.
service-worker.js Failed to load resource: net::ERR_INTERNET_DISCONNECTED
我不认为main.js正在被服务工作者缓存,但我可能错了。任何想法?
这是请求的package.json:
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"localforage": "^1.5.0",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-scripts": "1.0.10",
"react-toggle": "^4.0.1",
"recordrtc": "^5.4.2",
"squat": "^0.1.0",
"sw-precache": "^4.0.0",
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"homepage": "./"
}
是否存在sw-cache的最大文件大小?
答案 0 :(得分:1)
为了使Web应用程序脱机工作,您必须首先访问带有Internet的页面,然后通过浏览器进行缓存,如果您已访问具有Internet的页面,请确保在构建文件夹中的文件 service-worker.js 存在