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 );