Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google chrome devtools 如何知道我的index.html是否正在CRA应用程序中缓存?为什么它不出现在“网络”选项卡中?_Google Chrome Devtools_Create React App_Browser Cache_Cache Control - Fatal编程技术网

Google chrome devtools 如何知道我的index.html是否正在CRA应用程序中缓存?为什么它不出现在“网络”选项卡中?

Google chrome devtools 如何知道我的index.html是否正在CRA应用程序中缓存?为什么它不出现在“网络”选项卡中?,google-chrome-devtools,create-react-app,browser-cache,cache-control,Google Chrome Devtools,Create React App,Browser Cache,Cache Control,我想为我的index.html设置缓存控制:无缓存 对于我的js区块,我可以在我的开发工具的网络选项卡中找到它们,并在那里查看标题: 但是我的index.html不在网络选项卡中: 为什么呢?我如何确保它有缓存控制:no Cache头 我可以在源选项卡中看到索引 该应用程序由生产服务器(而不是CRA dev server)提供服务,并且CRA service worker被禁用。如果我没有弄错,您希望关闭服务器对index.html的缓存 有很多方法可以做到这一点。 以下是您可以在服务器端

我想为我的index.html设置
缓存控制:无缓存

对于我的js区块,我可以在我的开发工具的网络选项卡中找到它们,并在那里查看标题:

但是我的
index.html
不在网络选项卡中:

为什么呢?我如何确保它有
缓存控制:no Cache

我可以在源选项卡中看到索引


该应用程序由生产服务器(而不是CRA dev server)提供服务,并且CRA service worker被禁用。

如果我没有弄错,您希望关闭服务器对index.html的缓存

有很多方法可以做到这一点。 以下是您可以在服务器端执行的一些配置

NGINX:(NGINX.conf)

IIS:(web.config)



配置。

我在“网络”选项卡中没有看到标记为“索引”的请求的原因是,我没有直接请求
index.html
,而是在请求特定的应用程序内url时将其作为响应。我可以在当前URL下的devtools网络选项卡中找到相应的请求,在
type
列中有
text/html

您正在浏览器工具中搜索包含
index
的资源。您是否在加载的URL中包含
index.html
?或者按目录获取它,并在默认情况下提供该文件?加载其余文件的是索引。为什么要在网络调用中查看索引?@Joe:这是一个CRA单页应用程序,所以它应该包含在响应所有URL时使用。@juxhinbleta是的,索引加载其余的资源。但是,首先,它必须自己去做。我不太明白这个问题,我知道。我已尝试设置缓存控制。我现在想测试它是否设置正确。这就是为什么我想在我的网络选项卡中定位index.html。如果您在控制台中没有看到index.html,可能您的域名就是index.html。这是因为index.html在服务器上配置了“默认页面”。请检查如何在服务器上使用URL重写引擎。
location / {
    gzip_static on;
    try_files $uri @index;
}

location @index {
    add_header Cache-Control no-cache;
    expires 0;
    try_files /index.html =404;
}
<?xml version="1.0" encoding="UTF-8"?>
<configuration>    
  <location path="index.html">
    <system.webServer>
      <httpProtocol>
        <customHeaders>
          <add name="Cache-Control" value="no-cache" />
        </customHeaders>
      </httpProtocol>
    </system.webServer>
  </location>    
</configuration>