When coding HTML, browser doesn't always detect changes

前端 未结 6 807
自闭症患者
自闭症患者 2021-01-21 11:11

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 change

相关标签:
6条回答
  • 2021-01-21 11:23

    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.

    Quote from chrome dev tools (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

    .

    enter image description here

    0 讨论(0)
  • 2021-01-21 11:26

    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)

    0 讨论(0)
  • 2021-01-21 11:27

    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?)

    0 讨论(0)
  • 2021-01-21 11:27

    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

    0 讨论(0)
  • 2021-01-21 11:42

    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).

    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."

    Source : 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.

    0 讨论(0)
  • 2021-01-21 11:43

    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.

    0 讨论(0)
提交回复
热议问题