Recently encountered a strange problem: when the page nested multiple iframe, the page contained in the IFRAME will not be able to see the latest page information.
Initial solution, add a random number or timestamp to the page address suffix that the Iframe points to. This ensures that each time the page is loaded, the browser will know that it is the most recent page. To be blunt is to deceive the browser, avoid the disaster of cache. (This is the way to find a seemingly workable, root-rooted approach from Stack Overflow and CSDN.) )
Sample Code:
Generate random numbers by JS and pass data numbers as parameters to page addresses
<script type= "Text/javascript" >var randomnumber=math.floor (Math.random () *100000); document.write (' <iframe src= ' xxxx.aspx?_= ' +randomnumber+ ' ></iframe> '); </script>
The way to pass the time stamp
<script>var ts=New Date (). GetTime () document.write (' <iframe src= ' xxxx.asp?_= ' + ts+ ' ></iframe> ');d ocument.write (' <iframe src= "xxxxxx.asp?_= ' +ts+ '" ></iframe> " );d ocument.write (' <iframe src= ' xxxxxxxx.asp?_= ' +ts+ ' ></iframe> '); </script>
But this phenomenon is still, it is almost collapsed. I still look in this direction, after all, the Iframe generation cache is the source. Since the browser side in this way still cannot solve. Had to start from the server side, suddenly a brilliant, IIS seems to have a mechanism to automatically retain the cache.
It seems that the distance from the root of the total treatment is not far. Start the VM on the test environment, get IIS up and start with a configuration item that attracts me. "HTTP response header", because the most early in the processing of this method is the use of JS to force the removal of browser cache (can be referred to as follows, although this method is not cured, but there should be a need for this way of code friends).
< meta http-equiv = "Pragma" CONTENT = "No-cache" > < meta http-equiv = "Cache-control" CONTENT = "No-cache, Must-revalidate" > < meta http-equiv = "Expires" CONTENT = "Wed, 1997 08:21:57 GMT" >
Start configuring the HTPP response header.
1. Enter IIS to find the legendary "HTTP response header" and enter the HTTP response header
2. Add custom HTTP Response headers
The problem has finally been solved.
Page nested Iframe generation cache causes page data not to refresh issues