javascript - 浏览器可能不使用缓存

标签 javascript angular caching webpack browser

我正在使用 Webpack 4,并且在使用 Webpack devServer 时处于热模块替换模式。

出于某种原因,即使我使用哈希值,chrome 也会继续下载 bundle 。

输出:

Hash: 23594d99dc21755c5643
Version: webpack 4.17.1
Time: 1901ms
Built at: 2018-08-30 08:48:18
                           Asset       Size  Chunks             Chunk Names
        a17719b06f0064365b32.css   35 bytes       0  [emitted]  main
0.210b787809a8d87a8b98.bundle.js  501 bytes       0  [emitted]  main
1.640168cdfaffafd85d00.bundle.js    111 KiB       1  [emitted]  vendors~main
  ff4dc475b068a1649cf3.bundle.js   1.43 KiB       2  [emitted]  runtime
                      index.html  417 bytes          [emitted]
Entrypoint main = ff4dc475b068a1649cf3.bundle.js 1.640168cdfaffafd85d00.bundle.js a17719b06f0064365b32.css 0.210b787809a8d87a8b98.bundle.js
[60] ./src/main.css 39 bytes {0} [built]
[62] ./src/index.js + 1 modules 765 bytes {0} [built]
     | ./src/index.js 97 bytes [built]
     | ./src/component.js 643 bytes [built]
    + 61 hidden modules
Child html-webpack-plugin for "index.html":
     1 asset
    Entrypoint undefined = index.html
    [2] (webpack)/buildin/global.js 489 bytes {0} [built]
    [3] (webpack)/buildin/module.js 497 bytes {0} [built]
        + 2 hidden modules
Child mini-css-extract-plugin node_modules/css-loader/index.js!src/main.css:
    Entrypoint mini-css-extract-plugin = *
    [0] ./node_modules/css-loader!./src/main.css 194 bytes {0} [built]
        + 1 hidden module

从 Chrome 清除缓存后: enter image description here 第二次刷新后不清除缓存: enter image description here

我的问题:

  1. 为什么粗体(黄色)包没有从磁盘缓存加载?

  2. localhostng-validate.js 文件是什么? (我没有任何 Angular 依赖性)。


链接到我的 Playground 项目:https://github.com/stavalfi/webpack-demo

最佳答案

Chrome 不会重新下载这些文件。但它必须发出请求以确保文件没有更改。响应状态为 304(“未修改”)。该请求仍然需要几个字节来检查文件更改。

ng-validate.js 从“content-script”调用,表明可以从扩展调用它。您可以通过禁用所有扩展程序(或在隐身模式下)访问同一页面来检查这一点。

关于javascript - 浏览器可能不使用缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52090238/

相关文章:

javascript - clearInterval 也没有像我期望的那样工作

javascript - 将angularjs ng-repeat应用于owl-carousel

angular - Ionic 3 如何使用 textarea ngModel 和默认值?

css - Angular - 在 index.html 中包含 CSS 文件

javascript - 单击菜单项时保留悬停效果

javascript - 在 index.html 之外访问 Cordova navigator.camera 插件未定义

angular - 仅编译和发布 Angular 应用程序的一部分

php - CodeIgniter 是否缓存 CSS 等资源?

hibernate - Hibernate 二级缓存的解决方案

javascript - Gatsby v2 项目中的缓存问题