我注意到一个奇怪的警告信息,当使用谷歌chrome检查器(F12)查看下载的资源:

注意显示临时标题

我发现一些可能相关的东西,网络面板:添加临时请求头的警告,但我不能完全理解它。相关问题可以发现Chrome块请求以及XMLHttpRequest无法加载。未加载的资源显示警告:显示临时标头。

与第一个问题类似,我的资源被阻塞了,但后来自动加载了相同的资源。不像第二个问题,我不想解决任何问题;我想知道这条信息是什么意思以及我为什么收到它。


当前回答

这个报头显示的原因是:你的请求没有发送到远程。

它通常由

扩展已经阻止您的请求 Chrome使用自己的缓存获取您的资源

Chrome无法从尚未发出的请求中获得请求头。

chrome的最新版本显示:

只有临时头是可用的,因为这个请求不是通过网络发送的,而是从本地缓存提供的, 它不存储原始请求头。 禁用缓存以查看完整的请求头

其他回答

I've had this come up very recently (today in fact) where I've had an AJAX call go out to the server and Chrome fires off the "Caution: Provisional headers are shown." In the server side PHP scripting, there are MySQL queries that can be pretty much instant or take a few seconds depending on the given scenario. My server response isn't sent back to the browser until the queries are completed. I've found I get this error only when time consuming queries (up to a few seconds total) are being done and prevent the response from being sent back.

我的场景涉及到一个非常罕见的可能性,即必须通过添加/删除数百个天气模型输出列来更改一个表……因此,迭代ALTER TABLE查询循环会导致响应延迟。

我遇到过这个,当我从https切换到http时,它就消失了。我们在开发中使用的SSL证书没有经过第三方的验证。它们只是本地生成的开发证书。

同样的调用在Chrome Canary和Firefox中也能正常运行。这些浏览器似乎不像Chrome那样严格要求SSL证书。调用将失败在Chrome与“警告:临时头…”消息。

我认为/希望当我们在阶段和prod中使用合法的SSL证书时,我们将不再在Chrome中看到这种行为。

这种情况(仅针对跨源请求)也可能发生,因为有一种名为站点隔离的新功能

本页详细介绍了问题和解决方案。也就是去chrome://flags/#site-isolation-trial-opt-out,把这个设置改为“Opt-out”,然后重新加载chrome。

这是一个众所周知的问题。然而,该页面说它在chrome 68中是固定的,但我正在运行chrome 68,我仍然有这个问题。

在AJAX URL属性中发送参数时,我遇到了这个问题 http://10.165.10.160:82/services?param1=xxxx&param2=xxxx

如果你想执行一个get请求(例如发送参数化url),不要在url属性中添加它们,而是在数据对象中添加:

        <script>
        $.ajax({
        url: "http://10.160.10.160:82/services/STD_ERROR.php",
        data: {
            StatusText: StatusText,
            Status: Status,
            UserCode: UserCode,
            FUNC_CODE: FuncCode,
            ErrorDescription: ErrorDescription
        },
        type: "GET",
        crossDomain: true,
        cache: false
    }).done(data => {
        console.log(data)
    }).fail(function(xhr, status, error) {
        console.log(xhr.ErrorDescription)
    });
</script>

这可能是CORS的问题。 尝试为你的api启用CORS。

为WebApi

  var cors = new EnableCorsAttribute("*", "*", "*");
            config.EnableCors(cors);