The difference between javascript:location.reload () and Location.replace () and the effect on the image cache.

Source: Internet
Author: User

There was a time when I did not clean up the temporary files (cache files) of IE, when I cleaned up, I suddenly found a problem.

I opened a Web site, the picture default cache for one months, but I found that when I upload pictures or delete pictures after the image is re-cached, it means that when I upload new images or delete images, all the original images on the page are re-loaded, re-cached.

From this point of view, the cache of the image itself has no meaning at all.

I looked at the JavaScript code of the Web page and found that after uploading or deleting it, the call was Location.reload ();

Does this location.reload () not only reload the page, but all the resources on the page will be re-loaded.

I searched the internet for a bit and said this location.reload (Boolean state); There is an optional parameter, and the default is False.

I can go through my tests either: location.reload () or Location.reload (true) will reload all the pictures on the page when the page is refreshed. As their introduction says, Location.reload () is the equivalent of pressing the F5 key on the Web page to refresh.

But for my current application, I just want to refresh the content of the page and not let the previously loaded cached pictures reload again.

This is important, if every refresh is loaded with all the pictures, this will be a very waste of bandwidth and resources for the server.

I also see another way to refresh the page online: Location.replace ();

Window.location.reload () or document.location.reload (); 2 different ways

After I tested the location.replace () to replace the original Location.reload (), it was possible to update the contents of the page without reloading the previously existing images in the IE cache, so that the cache of the image itself was meaningful.

2010-11-06

The difference between javascript:location.reload () and Location.replace () and the effect on the image cache.

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.