编码HTML时,浏览器并不总是检测到更改

时间:2022-10-30 23:28:05

When I'm coding HTML and CSS and load the page in the browser to check changes, sometimes it doesn't update for a while. This obviously causes problems with incremental changes where it's hard to tell if it's changed to suit my latest change or not.

当我编写HTML和CSS并在浏览器中加载页面以检查更改时,有时它不会更新一段时间。这显然会导致增量更改出现问题,因为很难判断它是否已更改为适合我的最新更改。

I was wondering if there was a way around this? Possibly a browser (or mode) which is especially for this situation that doesn't have this behaviour?

我想知道是否有办法解决这个问题?可能是浏览器(或模式),特别是对于没有这种行为的情况?

6 个解决方案

#1


3  

Try Ctrl+F5 on Windows or Cmd+Shift+R on OSX, this will avoid your browser reading its cache when loading the page (at least when it's Chrome or Firefox)

在Windows上尝试Ctrl + F5或在OSX上尝试Cmd + Shift + R,这样可以避免浏览器在加载页面时读取缓存(至少在Chrome或Firefox时)

#2


2  

It is mostly because of browser cache.

这主要是因为浏览器缓存。

Just a suggestion(You may find it useful, As an addition to other answers):

只是一个建议(您可能会发现它很有用,作为其他答案的补充):

If you are on chrome then there is an option to disable cache while the dev toolbar is open. It works for me to ensure there is no caching while I am developing. (I keep my dev toolbar open all the time while developing so it works for me), Here is the screen shot.

如果您使用的是chrome,则可以选择在开发工具栏打开时禁用缓存。它对我有用,以确保在我开发过程中没有缓存。 (我开发时我的开发工具栏一直打开所以它对我有用),这是屏幕截图。

Quote from chrome dev tools (https://developers.google.com/chrome-developer-tools/docs/settings)

引用Chrome开发工具(https://developers.google.com/chrome-developer-tools/docs/settings)

General

Disable cache Will prevent the caching of resources ONLY for pages which have DevTools open. This will not disable caching if the DevTools are closed

禁用缓存仅阻止对已打开DevTools的页面缓存资源。如果DevTools关闭,这将不会禁用缓存

.

编码HTML时,浏览器并不总是检测到更改

#3


1  

You could try deleting your browser cache and reloading the page. In case of CSS I also found sometimes I will need to load the CSS file separately in my browser and refresh it to update.

您可以尝试删除浏览器缓存并重新加载页面。在CSS的情况下我也发现有时我需要在我的浏览器中单独加载CSS文件并刷新它以进行更新。

#4


1  

Sounds like your browser cache, you can test this by clearing it or doing a "hard refresh" to confirm.

听起来像您的浏览器缓存,您可以通过清除它或执行“硬刷新”来确认。

You will need to throw some no cache headers if you want to stop this permanently, you can do this from the web server or server-side code depending on your setup (see How to control web page caching, across all browsers?)

如果要永久停止此操作,则需要抛出一些无缓存标头,您可以从Web服务器或服务器端代码执行此操作,具体取决于您的设置(请参阅如何在所有浏览器中控制网页缓存?)

#5


1  

On windows refresh with CTRL + F5. The browser will not show from cache. Also in developer tools you can tell it not load from cache

在Windows上刷新CTRL + F5。浏览器不会从缓存中显示。同样在开发人员工具中,您可以告诉它不从缓存加载

#6


0  

Hmm could be a web server setting, caching request to your same resource. I used to see that a lot on tomcat with JSP. With tomcat we used to delete compiled classes ('work' folder), though, in your case with PHP you may check your server cache settings (files/sessions).

嗯可能是一个Web服务器设置,缓存对同一资源的请求。我曾经在JSP上看到很多关于tomcat的东西。使用tomcat我们曾经删除已编译的类('work'文件夹),但在您使用PHP的情况下,您可以检查您的服务器缓存设置(文件/会话)。

Example: "A typical web server, such as Apache, uses the time of file modification to inform a web browser of a requested page’s age, allowing the browser to take appropriate caching action. With dynamic web pages, the actual PHP script may change only occasionally; meanwhile, the content it displays, which is often fetched from a database, will change frequently."

示例:“典型的Web服务器(如Apache)使用文件修改时间来通知Web浏览器所请求页面的年龄,允许浏览器采取适当的缓存操作。对于动态Web页面,实际的PHP脚本可能只会更改偶尔;同时,它经常从数据库中提取的内容会经常变化。“

Source : http://www.sitepoint.com/caching-php-performance/

资料来源:http://www.sitepoint.com/caching-php-performance/

Another workaround would be to touch (add a space and save) your PHP file when you want it to reload.

另一种解决方法是在需要重新加载PHP文件时触摸(添加空格并保存)。

#1


3  

Try Ctrl+F5 on Windows or Cmd+Shift+R on OSX, this will avoid your browser reading its cache when loading the page (at least when it's Chrome or Firefox)

在Windows上尝试Ctrl + F5或在OSX上尝试Cmd + Shift + R,这样可以避免浏览器在加载页面时读取缓存(至少在Chrome或Firefox时)

#2


2  

It is mostly because of browser cache.

这主要是因为浏览器缓存。

Just a suggestion(You may find it useful, As an addition to other answers):

只是一个建议(您可能会发现它很有用,作为其他答案的补充):

If you are on chrome then there is an option to disable cache while the dev toolbar is open. It works for me to ensure there is no caching while I am developing. (I keep my dev toolbar open all the time while developing so it works for me), Here is the screen shot.

如果您使用的是chrome,则可以选择在开发工具栏打开时禁用缓存。它对我有用,以确保在我开发过程中没有缓存。 (我开发时我的开发工具栏一直打开所以它对我有用),这是屏幕截图。

Quote from chrome dev tools (https://developers.google.com/chrome-developer-tools/docs/settings)

引用Chrome开发工具(https://developers.google.com/chrome-developer-tools/docs/settings)

General

Disable cache Will prevent the caching of resources ONLY for pages which have DevTools open. This will not disable caching if the DevTools are closed

禁用缓存仅阻止对已打开DevTools的页面缓存资源。如果DevTools关闭,这将不会禁用缓存

.

编码HTML时,浏览器并不总是检测到更改

#3


1  

You could try deleting your browser cache and reloading the page. In case of CSS I also found sometimes I will need to load the CSS file separately in my browser and refresh it to update.

您可以尝试删除浏览器缓存并重新加载页面。在CSS的情况下我也发现有时我需要在我的浏览器中单独加载CSS文件并刷新它以进行更新。

#4


1  

Sounds like your browser cache, you can test this by clearing it or doing a "hard refresh" to confirm.

听起来像您的浏览器缓存,您可以通过清除它或执行“硬刷新”来确认。

You will need to throw some no cache headers if you want to stop this permanently, you can do this from the web server or server-side code depending on your setup (see How to control web page caching, across all browsers?)

如果要永久停止此操作,则需要抛出一些无缓存标头,您可以从Web服务器或服务器端代码执行此操作,具体取决于您的设置(请参阅如何在所有浏览器中控制网页缓存?)

#5


1  

On windows refresh with CTRL + F5. The browser will not show from cache. Also in developer tools you can tell it not load from cache

在Windows上刷新CTRL + F5。浏览器不会从缓存中显示。同样在开发人员工具中,您可以告诉它不从缓存加载

#6


0  

Hmm could be a web server setting, caching request to your same resource. I used to see that a lot on tomcat with JSP. With tomcat we used to delete compiled classes ('work' folder), though, in your case with PHP you may check your server cache settings (files/sessions).

嗯可能是一个Web服务器设置,缓存对同一资源的请求。我曾经在JSP上看到很多关于tomcat的东西。使用tomcat我们曾经删除已编译的类('work'文件夹),但在您使用PHP的情况下,您可以检查您的服务器缓存设置(文件/会话)。

Example: "A typical web server, such as Apache, uses the time of file modification to inform a web browser of a requested page’s age, allowing the browser to take appropriate caching action. With dynamic web pages, the actual PHP script may change only occasionally; meanwhile, the content it displays, which is often fetched from a database, will change frequently."

示例:“典型的Web服务器(如Apache)使用文件修改时间来通知Web浏览器所请求页面的年龄,允许浏览器采取适当的缓存操作。对于动态Web页面,实际的PHP脚本可能只会更改偶尔;同时,它经常从数据库中提取的内容会经常变化。“

Source : http://www.sitepoint.com/caching-php-performance/

资料来源:http://www.sitepoint.com/caching-php-performance/

Another workaround would be to touch (add a space and save) your PHP file when you want it to reload.

另一种解决方法是在需要重新加载PHP文件时触摸(添加空格并保存)。