question
Recently, I used EasyUI to develop a background system. I found a strange problem during testing. $('dg').datagrid('reload'); When reloading the table data, I had no reaction at all. Later I found out that it was not that there was no response, but that the browser used cache.
Solution
There are several solutions summarized by netizens online:
1. Add a timestamp after the url, so that the url accessed in the first load and reload are inconsistent, making the system unable to use IE cache. Through testing, it was found that the EasyUI request already has a string of random numbers _145232xxx after it was requested, but ie still uses cache. Later, I added rand=xxx(random number generated by Math.rand()) to the requested js and would not use cache. (I tested from ie8 to ie11)
2. Use a similar way to adding <meta> to <head> to clear the cache:
The code copy is as follows:
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
Unfortunately, like many netizens, I failed this method. :(
3. Declare the method corresponding to the datagrid load as 'POST', this solution is the fastest. But there are several problems:
•If the server interface does not support POST mode, it will be stopped.
•If the server interface can control it itself, this way of compromise for the front-end will lead to the interface being not RESTful at all! You should know that the RESTful interface is basically GET for query design.
Summarize
So it is the first method. Adding random numbers yourself in the url is easy to use. Forgive me for being obsessed with the code that I don’t want to change the server interface_(:з」∠)_.