简体   繁体   English

Apache PHP localhost 更改响应太慢

[英]Apache PHP localhost changes response too slow

In my PHP localhost project, If I change something in my code [ex: echo a line] and refresh my browser the changes did not show immediately .在我的 PHP localhost 项目中,如果我在代码中更改某些内容 [例如:回显一行] 并刷新我的浏览器,更改不会立即显示 I have to wait for 10-15 seconds and refresh my browser then it shows the changes.我必须等待10-15 秒并刷新我的浏览器,然后它会显示更改。 I tried on different browsers.我尝试了不同的浏览器。

Note: I'm just using the apache server.注意:我只是使用 apache 服务器。 And I don't have any error to start and stop the apache server.而且我在启动和停止 apache 服务器时没有任何错误。

Its probably the browser's cache.它可能是浏览器的缓存。 And the browser checks for updates in the website's pages every 10-15 secs, or precisely if its been an amount of time since the last cache, it rechecks if the cache is up to date, so it updates there.并且浏览器每 10-15 秒检查一次网站页面中的更新,或者确切地说,如果它是自上次缓存以来的一段时间,它会重新检查缓存是否是最新的,因此它会在那里更新。

See HTTP Cache .请参阅HTTP 缓存

You can stop it by adding:您可以通过添加来停止它:

Header always set Cache-Control "no-cache"
Header always set Pragma "no-cache"

But, cache can really improve the user page load speed for static content.但是,缓存确实可以提高 static 内容的用户页面加载速度。 So, think more about this before setting this in a production server.因此,在将其设置在生产服务器中之前,请多考虑一下。

You should usually always disable cache on development servers.您通常应该始终禁用开发服务器上的缓存。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM