html implements iframe caching, html caching, see also caching iframe ajax flash

What's the scariest thing you've ever done developing a program? It's when you don't know something and you hit the cache when testing it.

Testing means that we have to constantly modify, but when you modify the file (on the server side) and then refresh the browser, you still see the original interface, no matter how you brush it, it is useless, just when you are depressed, Accidentally closed the browser, reopened the browser, entered the address just now, but found that it has changed, you must have the urge to smash the computer at this time.

You may say use ctrl+F5, but the following situations cannot be solved by ctrl+F5.

iframe

The general practice is to include an iframe in the static html file to call a php file. After you modify the php file, you find that when you refresh the page, the content in the iframe has not changed, and ctrl+F5 does not work. At this time, you can consider using the iframe. Right-click on the displayed place, and then refresh, which means to refresh outside the iframe, the entire static file is refreshed, and right-clicking on the iframe to refresh is the refreshed iframe;

ajax

A static page, test.htm, calls a php file through ajax, passing a parameter, such as test.php? , the php file returns an xml, and then fills the value of the element in the xml to the htm page through js, the test is correct, and then changes the php file, and when it is refreshed, the content just filled is gone. I thought that the php was repaired when I just modified it, so I kept testing the php file, but it was still invalid.

In fact, even if you didn't change the php file just now, it will be gone if you flash it again. Because when refreshing again, the parameters passed twice are the same, ajax will not submit to the server, halo, the solution is to add another parameter, such as adding a random number after, &rand=5, the number can be passed through js to get the random number function.

flash

Today, I want to do something, a flash file. This flash file calls an xml file. There are two elements in the xml file. By changing the values ​​of these two elements, the content displayed by the flash is also different. Then I write a php file, get two parameters, and then update an xml file through these two parameters. After the update is completed, call the flash file, and you can see the content in the flash. That is to say, the parameters passed to the php file are different, and the content in the flash is also different.

Then start the test, first manually change the xml file, the result is useless. Guessed it was the cache, but flash didn't give the right button to refresh. After a very depressing period of time, I reopened a browser window and the result was correct.

HTML caching is to store part of the data sent by the server to the client, so that when the same request is encountered again, the data can be directly fetched from the client, saving bandwidth and time. This is definitely something we programmers don't want to see, because we want the same request to be fetched from the server every time.

1. F5 refresh

2. CTRL+F5 refresh

3. Re-open a browser window, CTRL+F5 to refresh

4. Add a parameter to the cached thing

The above is just the solution to the problem I encountered. It may not be very good, but it should solve the problem temporarily. If you have a better method, please suggest.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324136469&siteId=291194637