Chrome无法识别我对javascript文件所做的更改并加载旧代码? [英] Chrome doesn't recognize my changes on my javascript file and loads old code?

查看:54
本文介绍了Chrome无法识别我对javascript文件所做的更改并加载旧代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经坐在这里将近一个小时,以测试我正在建立的网站.由于我想查看代码中的新更改,因此我重新加载了,但是它正在重新加载旧的代码.我打开了devetools进行硬重载和empy高速缓存硬重载,它们都加载了我的旧代码.我进入了隐身模式,它做了同样的事情.我再次进入devtools以从设置中禁用缓存,并在网络"标签中检查了禁用缓存;它仍然缓存我的旧代码.清除缓存的附加组件也无法正常工作.伙计,我以前没有遇到过这个问题,它只是在昨晚才发生,今天最糟糕.

I have been sitting here for almost an hour here to test the website I'm building. Since I wanted to see the new changes from my code I reloaded, but it was reloading old one. I opened the devetools to hard reload and empy cache hard reload, they both load my old code. I went to incognito mode and it did the same thing. I went to devtools again to disable the cache from the settings and checked the disable cache in the network tab; it still cache my old code. Add-ons to clear the cache didn't work as well. Man, I haven't had this problem before and it only happened last night and it's worst today.

我现在迷路了,因为chrome无法从我的javascript文件中加载新的更改.有解决方案吗?

I'm so lost now since chrome doesn't load my new changes from my javascript file. Is there a solution for this?

推荐答案

此问题的一种解决方案是强制重新加载资源以避免缓存.您可以使用http get参数修改网址:

One solution for this problem is to force reloading the resource in order to avoid the cache. You can get this modifying the url with http get parameters:

更改:

<script src="myscripts.js"></script>

收件人:

<script src="myscripts.js?newversion"></script>

newversion 可以是任何字符串,因为它将被忽略.一个有用的选项是使用代码的日期或版本.

Where newversion can be any string as it will be ignored. A useful option is to use the date, or version, of your code.

当我遇到同样的问题并希望确保所有客户端(不仅仅是我自己的浏览器!)都将运行新版本的代码时,我发现此解决方法特别有用.

I found this workaround particularly useful when I came across this same problem and wanted to ensure that all clients (not just my own browser!) would run the new version of the code.

这篇关于Chrome无法识别我对javascript文件所做的更改并加载旧代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆