javascript - Front-end development. Local static files are frequently modified. How to solve the cache problem during preview?
淡淡烟草味
淡淡烟草味 2017-05-16 13:24:25
0
8
582

Our company downloads the project from SVN to the local, and then uploads it to the server after modifying it locally.
The current problem is that when several styles are modified locally, or externally linked js is previewed in the browser, the changes cannot be seen due to caching, and the cache can only be manually cleared. However, it is more troublesome when modifications are frequent. After looking at the method of adding timestamps to fis, it seems that the project is only reconfigured when deploying or updating. Is there any good method for this kind of local modification?

淡淡烟草味
淡淡烟草味

reply all(8)
为情所困

Disable cache through chrome
chrome dev tools > networks > disalbed cache, see the picture below

Ty80

Add version number after css and js files

phpcn_u1582

You can use Chrome’s clean cache plug-in. Just click the button of this plug-in every time you refresh the page. You don’t need Chrome’s refresh button

我想大声告诉你

It is recommended to use a build tool such as webpack or gulp. When building the project, put the version number after the file to trigger the browser request.

给我你的怀抱

Develop and deploy front-end code

左手右手慢动作

After each modification, you can add a timestamp after the file to ensure that the requested file is a newly modified file, like the following
<link rel="stylesheet" href="css/main.css?i=2017051101">
<script src="js/config.js?i=2017051101"></script>

PHPzhong

The button on the page can be forced to refresh
Button binding event location.reload()

我想大声告诉你

CMD + SHIFT + R

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!