Home  >  Q&A  >  body text

javascript - Front-end development. Local static files are frequently modified. How to solve the cache problem during preview?

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?

淡淡烟草味淡淡烟草味2712 days ago584

reply all(8)I'll reply

  • 为情所困

    为情所困2017-05-16 13:26:25

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

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 13:26:25

    Add version number after css and js files

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-16 13:26:25

    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

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-16 13:26:25

    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.

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-16 13:26:25

    Develop and deploy front-end code

    reply
    0
  • ringa_lee

    ringa_lee2017-05-16 13:26:25

    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>

    reply
    0
  • PHPz

    PHPz2017-05-16 13:26:25

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

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-16 13:26:25

    CMD + SHIFT + R

    reply
    0
  • Cancelreply