Html 本地主机不会立即更新
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12683417/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
localhost Won't Immediately Update
提问by MillerMedia
I have been using XAMPP to connect to localhost to do editing on my computer for websites. I have been using it for over a year now and in the past whenever I would update the local file, I could refresh the page on my browser and it would immediately update. Now, I can't get it to update even if, for example, an image file has changed.
我一直在使用 XAMPP 连接到 localhost 以在我的计算机上对网站进行编辑。我已经使用它一年多了,过去每当我更新本地文件时,我都可以刷新浏览器上的页面,它会立即更新。现在,即使例如图像文件已更改,我也无法更新它。
I'm wondering if it's an issue with cookies (which I haven't had in the past). Is there a common reason that this happens? I couldn't find anything upon a search. Thanks for the help!
我想知道这是否是 cookie 的问题(我过去没有遇到过)。发生这种情况是否有共同的原因?我在搜索中找不到任何东西。谢谢您的帮助!
回答by Gabriel Harper
First thing to try would be clearing browser history/cache and reloading the browser.
首先要尝试的是清除浏览器历史记录/缓存并重新加载浏览器。
If you enabled some kind of caching that might also explain it.
如果您启用了某种缓存,这也可以解释它。
You could test by creating a newpage on localhost and see if it works. If so, then check that any pages you're changing on localhost are actually being updated (check the file modified times and close/reload the source to see if the changes are actually there).
您可以通过在 localhost 上创建一个新页面来进行测试,看看它是否有效。如果是这样,请检查您在 localhost 上更改的任何页面是否实际正在更新(检查文件修改时间并关闭/重新加载源以查看更改是否确实存在)。
回答by Mustafa Serkan ?mero?lu
Just delete all the temporary browser related files, I used C-Cleaner.
Add header <meta http-equiv="Cache-control" content="no-cache">
只需删除所有与浏览器相关的临时文件,我使用了 C-Cleaner。添加标题<meta http-equiv="Cache-control" content="no-cache">
I solved use this method.
我解决了使用这种方法。
回答by Dixel
I've had the same problem and solved it simply by reloading the current page, ignoring cached content. There is a shortcut that I know works for Chrome and Firefox:
我遇到了同样的问题,只需重新加载当前页面,忽略缓存内容即可解决。我知道有一个快捷方式适用于 Chrome 和 Firefox:
Ctrl + Shift + R
Ctrl + Shift + R
I hope it will make life easier for some people.
我希望它能让一些人的生活更轻松。
回答by boofplahboof
I thought this was happening with me but I had basically made a very basic but deceptive error: I had moved the .php file to a new folder on the server AFTER having openend it in Notepad to edit it. I had entered the new URL in the Web browser to account for this move in order to view the page generated from the .php file but I was still working on the file in Notepad openeed BEFORE I moved it. Consequently, I was saving changes to the file pre-move and not able to understand why on earth it wasn't changing the page in the browser. Dumb perhaps but had me perplexed.
我认为这发生在我身上,但我基本上犯了一个非常基本但具有欺骗性的错误:在记事本中打开它以对其进行编辑后,我已将 .php 文件移动到服务器上的一个新文件夹中。为了查看从 .php 文件生成的页面,我已在 Web 浏览器中输入了新 URL 以说明这一移动,但在移动它之前,我仍在用记事本 openeed 处理该文件。因此,我在移动前保存了对文件的更改,但无法理解为什么它没有更改浏览器中的页面。也许愚蠢,但让我感到困惑。
回答by Calvin
I know this is an old question but hopefully, my answer helps someone in the future. The solution that worked for me was to delete the folder containing my code in htcdocs and replace it with an updated folder of code. This required me to keep an original folder of my code in a different folder which I modified with updates and made a copy of to replace the outdated code stored in htcdocs.
我知道这是一个老问题,但希望我的回答能在未来对某人有所帮助。对我有用的解决方案是删除 htcdocs 中包含我的代码的文件夹,并将其替换为更新的代码文件夹。这要求我将我的代码的原始文件夹保存在另一个文件夹中,我用更新修改了该文件夹并制作了副本以替换存储在 htcdocs 中的过时代码。
回答by XuanNing Ren
I met the same problem when I used xampp with chrome(mac). I tried several ways to solve it such as clearing the chrome or adding extra code in the html file. But neither works. Finally, I simply solved this problem by using safari instead chrome.
当我将 xampp 与 chrome(mac) 一起使用时,我遇到了同样的问题。我尝试了几种方法来解决它,例如清除chrome或在html文件中添加额外的代码。但两者都不起作用。最后,我简单地通过使用 safari 而不是 chrome 解决了这个问题。
回答by mellonHead17
I experienced this is issue recently using Django 2.1. I tried every browser, cleared my cache multiple times, triple checked that I was using Python's SimpleHTTPServer in the same directory I was writing my code, and even did a full reboot... No luck.
我最近在使用 Django 2.1 时遇到了这个问题。我尝试了所有浏览器,多次清除缓存,三重检查我是否在编写代码的同一目录中使用了 Python 的 SimpleHTTPServer,甚至完全重新启动......运气不好。
Right before throwing my MacBook out the window, I solved the problem by changing my Debug
setting from False
to True
. Why did this work? I'm not quite sure since the documentation for this settingdoesn't mention that kind of behavior at all, but it was the only thing I could remember recently changing to possibly allude to this ghost bug. If anyone has a specific source to confirm this information, please comment and I will edit my answer.
在将 MacBook 扔出窗外之前,我通过将Debug
设置从更改False
为True
. 为什么这样做?我不太确定,因为此设置的文档根本没有提到这种行为,但这是我最近唯一记得的更改以可能暗示这个幽灵错误。如果有人有特定来源来确认此信息,请发表评论,我将编辑我的答案。
Hope this helps anyone about to Hulk smash their computer :-)
希望这可以帮助任何要砸碎绿巨人电脑的人:-)
回答by Derik
I've seen other people with the same problem. They've just moved to WAMP. If there is not a specific reason for you to stick with XAMPP you could give it a try. Hope this helps.
我见过其他人有同样的问题。他们刚刚搬到 WAMP。如果没有特定的理由让您坚持使用 XAMPP,您可以尝试一下。希望这可以帮助。
回答by Jay Movaliya
Clear Your Browser History or Cache.
清除浏览器历史记录或缓存。
Try the same with Different Browser that is if you are using Chrome then use Mozila and others or vice versa.
尝试使用不同的浏览器,如果您使用 Chrome,则使用 Mozila 和其他浏览器,反之亦然。