Page nested Iframe generation cache causes page data not to refresh issues

Source: Internet
Author: User
Tags browser cache

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.