Force page to reload from server instead of load the cached version

前端 未结 6 463
温柔的废话
温柔的废话 2021-01-02 04:20

I have webpage A. The user clicks on a form to submit data, and it takes him to webpage B. When he clicks the back button, I need webpage A to be refreshed from the server,

6条回答
  •  失恋的感觉
    2021-01-02 05:07

    I know this is old question and already have the answer (that not refreshing from the server). So I would like to share a solution using jQuery.

    $('#back-button').click(function(){
       setTimeout(location.reload(true), 1000);
    });
    

    Explanation:
    As you click the back button, the setTimeout will triggered after 1 second (1000 milliseconds). Then, the page will reload from the server as the parameter inside the reload is true.

    If you put true inside the reload it will reload from the server while if you put false it will reload from the cache. Source w3schools.

提交回复
热议问题