Up until now, I had always sent an AJAX request and run location.reload()
when the request is finished, updating the page. Recently, for some reason, the old input values are still kept when the page is reload. I suspect the culprit is Firefox's cache, because when I remove the cache or just reload the page normally with F5, the input values are updated as well. The same function still work on Chrome and Edge.
I tried out window.location.href = window.location.href
, same thing happened.
I tried out window.location.replace(window.location.href)
, same thing happened.
I did my research and saw some people suggested location.reload(true)
, it worked perfectly. However, I also read that this method is deprecated and had been removed in some browsers already. I don't want to build my code base on such uncertainty.
Cache busting technique can lead to caching overhead, and I don't want to slow down the page performance.
Thus, my question is: which code can I write to tell the browser to do a forced reload, removing all cache?
I only want to remove cache in some functions, not all of them. I am not a fan of form.