What's the best way to deal with cache and the browser back button?

前端 未结 5 1786
心在旅途
心在旅途 2021-02-06 03:24

What\'s the best way to handle a user going back to a page that had cached items in an asp.net app? Is there a good way to capture the back button (event?) and handle the cache

5条回答
  •  没有蜡笔的小新
    2021-02-06 04:06

    As far as I know (or at least have read) is its best to try not to work in response to user events, but rather think "in the page"..

    Architect your application so it doesn't care if the back button is pushed.. It will just deal with it.. This may mean a little extra work from a development point of view, but overall will make the application a lot more robust..

    I.e if step 3 performs some data chages, then the user clicks back (to step 2) and clicks next again, then the application checks to see if the changes have been made.. Or ideally, it doesnt make any hard changes until the user clicks "OK" at the end.. This way, all the changes are stored and you can repopulate the form based on previously entered values on load, each and every time..

    I hope that makes sense :)

提交回复
热议问题