Compatible solution for page caching of IFRAME frameworks in IE and (Firefox) FF

Source: Internet
Author: User

Whether it is IE or Firefox, IFRAME is cached. Many developers may not pay attention to it,

Steamed Stuffed bun is developing a feast for millions of netizens in shangzhidu, Anhui Province

The second kill topic encountered a similar situation, even if your IFRAME address is a PHP dynamic page, the browser cache will appear,

At first, I thought it would be okay to use the header to prohibit caching on the PHP page, but it does not seem to work .. ..

Let's take a look at how Firefox solves the page cache of the IFRAME framework,

A method seen on a foreign blog is as follows:

Hi

I have a page that contains an IFRAME. The contents of the IFRAME are created dynamically,
So every time I come to the page containing this iframe I want to force the IFRAME to refresh. I added these meta tags to the IFRAME's head:

 

<Meta http-equiv = "expires" content = "mon, 26 Jul 1997 05:00:00 GMT">
<Meta http-equiv = "last-modified" content = "SAT, 10 Nov 1997 09:08:07 GMT">
<Meta http-equiv = "cache-control" content = "no-store, no-cache, must-revalidate">
<Meta http-equiv = "Pragma" content = "no-Cache">

 

And I also add a different random number to the IFRAME SRC each time:

 

< IFRAME SRC = "http://lab.wehefei.com/index.php?r=xO9X7hEp2wgW5ZTSB38dCrKQnkyq4MA_" WIDTH = 900 HEIGHT = 600 >

 

 

 

It works in Firefox, but in IE6 it still caches the old page.

 

Http://lab.wehefei.com

 

Amount. Do you understand ??? Hey, fortunately, my computer English is very good. Haha .,.,.. I will not translate .,

In Firefox, the IFRAME framework provides two page caching methods:

1. Use the above meta header information. Of course, if you use a PHP dynamic page, you 'd better also send the header information to disable caching.
2. Add a random number. After HTML. Haha

Below. We can see that there are two methods to solve the IFRAME cache problem in IE:

(1) The IFRAME name is randomly changed each time the homepage is refreshed;

(2) assign a random get parameter to the SRC path page of IFRAME each time the homepage is refreshed, for example:

<IFRAME src = "http://www.example.com/thepage.html" name =" aframe "> </iframe>
<SCRIPT type = "text/JavaScript">
Document. Frames ['aframework']. Location. href + = (document. Frames ['aframework']. Location. href. indexof ("?") ! =-1? "?" : "&") + (New date (). gettime ();
</SCRIPT>

 

Source: Hefei network UED http://lab.wehefei.com

 

 

In fact, there are still some methods. during the development process, the Steamed Stuffed Bun encounters a situation that, after each second-kill product, click it and find that the number of second-kill statistics pages in PHP remains unchanged,

.. I have a problem with the cache of the IFRAME framework.

The actual development process of Steamed Stuffed bun is as follows:

The link in the topics of Steamed Stuffed bun is a static page,

Add the timestamp parameter to the URL of these frameworks. Example: & t = 1123231212

Then, on the loaded PHP page, use the header information to prohibit data caching. Oh my Lady Gaga, OK, haha ,,

 

Amount. In other words, the development lies in the summary in practice, and the E text is better. Otherwise, you will not be able to understand the E text of foreigners. Alas. ,. ,

Source: Hefei network UED http://lab.wehefei.com

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.