One Parameter solves the webbrowser cache problem in the application and one parameter solves the webbrowser cache problem in the application.

Source: Internet
Author: User
Tags delete cache
One Parameter solves the webbrowser cache problem in the application

In the past two days, when the webbrowser control is used in the application to load webpages, a problem occurs. When the same address and URL with the same parameters are repeatedly loaded, webbrowser will automatically load the local cache.

 

In order to solve this problem, I read a lot of related information online. Most of them refer to using winapi to delete cache files in the cache folder and cached data in the memory.

In this way, the cache can be deleted, but considering the performance, it is true that I need to delete the cache. However, images and JS caches are mandatory and cannot be deleted? Therefore, the method obtained on the Internet has never been considered.

 

Yesterday I suddenly remembered that I had a similar problem when I used to do the verification code.

You can often see that the address for updating the verification code is added with a random parameter to make the generated image more reproducible.

The main reason for adding parameters is the IE cache. It seems that the IE cache is based on the URL address.

Can the same principle be applied to previous problems? With a try attitude, the T = datetime. Now. ticks parameter is added every time the connection is loaded, and the expected effect is achieved.

 

Therefore, a simple solution is provided:

String url = "http://www.xxxxx.com/a.aspx? A = 1 & B = C & T "= datetime. Now. ticks

Webbrowser1.navigate (URL );

In the past two days, when the webbrowser control is used in the application to load webpages, a problem occurs. When the same address and URL with the same parameters are repeatedly loaded, webbrowser will automatically load the local cache.

 

In order to solve this problem, I read a lot of related information online. Most of them refer to using winapi to delete cache files in the cache folder and cached data in the memory.

In this way, the cache can be deleted, but considering the performance, it is true that I need to delete the cache. However, images and JS caches are mandatory and cannot be deleted? Therefore, the method obtained on the Internet has never been considered.

 

Yesterday I suddenly remembered that I had a similar problem when I used to do the verification code.

You can often see that the address for updating the verification code is added with a random parameter to make the generated image more reproducible.

The main reason for adding parameters is the IE cache. It seems that the IE cache is based on the URL address.

Can the same principle be applied to previous problems? With a try attitude, the T = datetime. Now. ticks parameter is added every time the connection is loaded, and the expected effect is achieved.

 

Therefore, a simple solution is provided:

String url = "http://www.xxxxx.com/a.aspx? A = 1 & B = C & T "= datetime. Now. ticks

Webbrowser1.navigate (URL );

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.