简体   繁体   English

在我按下 Ctrl+F5 之前,我的代码不适用,有时也不起作用

[英]My codes don't apply until I press Ctrl+F5, and sometimes don't work eitherly

please help me on this, when I code (Html, Sass/css, Javascript), the changes don't apply until I press "Ctrl+F5" it happens every time I want to work again on my project, Im making WordPress costume theme And I use Xampp, VS code and Microsoft chromium based browser as my tools, I thought the problem from Xampp but when I install my theme on my online host, HALF OF CHANGES (STYLES AND JAVASCRIPT FUNCTIONS ) APPLIED, then I pressed Ctrl + F5 the changes applied again, I don't know what to do, please help.请帮我解决这个问题,当我编写代码(Html、Sass/css、Javascript)时,更改不适用,直到我按下“Ctrl+F5”时,每次我想再次处理我的项目时都会发生这种情况,我正在制作 WordPress 服装theme And I use Xampp, VS code and Microsoft chromium based browser as my tools, I thought the problem from Xampp but when I install my theme on my online host, HALF OF CHANGES (STYLES AND JAVASCRIPT FUNCTIONS ) APPLIED, then I pressed Ctrl + F5 再次应用更改,我不知道该怎么办,请帮助。 until today my Javascript doesn't work its like I didn't write any Javascript code.直到今天,我的 Javascript 都无法正常工作,就像我没有编写任何 Javascript 代码一样。

In some few cases it's not enough to reset with F5 or even CTRL-F5.在少数情况下,使用 F5 甚至 CTRL-F5 重置是不够的。 Here helps to really delete the cache in your browser.这有助于真正删除浏览器中的缓存。

If you use Chrome than you can disable in preferences the cache while using DevTools.如果您使用 Chrome,则可以在使用 DevTools 时在首选项中禁用缓存。 This helps me sometimes.这有时对我有帮助。 The little loss of perfomance doesn't bother me for testing.性能上的一点点损失并没有打扰我进行测试。

For achieve this on Chrome press F12 for opening the DevTools and than open the settings .要在 Chrome 上实现这一点,请按F12打开 DevTools,然后打开设置 There click on the preferences and mark disable cache .点击首选项并标记禁用缓存

在此处输入图像描述

It seems like a HTTP Caching problem: https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching好像是 HTTP 缓存问题: https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching

If you have the control over the HTTP server(nginx, apache or something like that), change the response header to include a Cache-Control: no-cache .如果您可以控制 HTTP 服务器(nginx、apache 或类似的东西),请更改响应 header 以包含Cache-Control: no-cache

If you don't have the control over the HTTP server, you can adding a version number parameter to the URL.如果您无法控制 HTTP 服务器,您可以在 URL 中添加版本号参数。

For example:例如:

Before a.js changed:a.js更改之前:

<script src="http://example.com/a.js?v=1"></script>

After a.js changed: a.js更改后:

<script src="http://example.com/a.js?v=2"></script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 代码在 Codepen 中有效,但在我的计算机中无效 - Codes Work In Codepen But Don't Work In My Computer 砌体不适用于moblie浏览器(chrome),并且仅当我重新加载(ctrl + f5)页面而不是刷新(f5)时才可在Chrome桌面版本上使用 - Masonry doesn't work on moblie browser (chrome) and only works on Chrome desktop version if I reload (ctrl+f5) the page, not on refresh (f5) 我不知道为什么我的 get 请求有时有效但有时无效(404 未找到) - I don't know why my get request sometimes works but sometimes doesn't (404 not found) JavaScript以及大写字母为何有时起作用而有时不起作用的原因 - JavaScript and why capital letters sometimes work and sometimes don't 我的 innerHTML 不起作用,我不知道为什么? - My innerHTML doesn't work and I don't know why? 我不知道为什么我的 backgroundImage 不起作用 - I don't how why my backgroundImage doesn't work 我的for循环不起作用,我也不知道为什么 - my for loop doesn't work and I don't know why 如果“oncontextmenu”事件和 ctrl+shift+i 不起作用,我如何打开开发工具? - How do I open dev tools if 'oncontextmenu' event and ctrl+shift+i don't work? 有时当我按下按钮时它有时会不起作用 - sometimes when I press the button it works sometimes it doesn't work java脚本代码在phonegap 2.9.0中不起作用 - java script codes don't work in phonegap 2.9.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM