How to disable http caching in applet

淺唱寂寞╮ 提交于 2019-12-01 08:23:35

问题


How can i disable http caching of all my http connections in my japplet? I dont want any of my http (request/response)to be cached.Regardless of the user settings in control panel\java\Temporary File Settings. Applet is signed and compiled with java1.6.
I am using URLConnection.class and my request to an 3rd party web service is being cached.
ie:
I can see my request url in Java Cache Viewer. http://www.service.com?param1=232&param2=2323232
Also i can find the responses in application ....users\data\sun\java\deployment\cache
responseline1
responseline2


回答1:


You can disable caches using URLConnection.setUseCaches(boolean)




回答2:


An easy way to break caching is to add a random value to the url ala:

String url = "http://www.example.com/?noCache=" + Math.Random();



来源:https://stackoverflow.com/questions/6747956/how-to-disable-http-caching-in-applet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!