Force browser to refresh css, javascript, etc

前端 未结 16 1829
花落未央
花落未央 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:43

    If you want to be sure that these files are properly refreshed by Chrome for all users, then you need to have must-revalidate in the Cache-Control header. This will make Chrome re-check files to see if they need to be re-fetched.

    Recommend the following response header:

    Cache-Control: must-validate
    

    This tells Chrome to check with the server, and see if there is a newer file. If there is a newer file, it will receive it in the response. If not, it will receive a 304 response, and the assurance that the one in the cache is up to date.

    If you do NOT set this header, then in the absence of any other setting that invalidates the file, Chrome will never check with the server to see if there is a newer version.

    Here is a blog post that discusses the issue further.

提交回复
热议问题