Force browser to refresh css, javascript, etc

前端 未结 16 1847
花落未央
花落未央 2020-11-29 19:16

I\'m developing a website based on Wordpress source code through XAMPP. Sometimes I change the CSS code, scrips or something else and I notice my browser takes time to apply

16条回答
  •  清歌不尽
    2020-11-29 19:48

    Try this:

    link href="styles/style.css?=time()" rel="stylesheet" type="text/css"
    

    If you need something after the '?' that is different every time the page is accessed then the time() will do it. Leaving this in your code permanently is not really a good idea since it will only slow down page loading and probably isn't necessary.

    I've found that forcing a style sheet refresh is helpful if you've made extensive changes to a page's layout and accessing the new style sheet is vital to having something sensible appear on the screen.

提交回复
热议问题