Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6624924

Network: UrlConnection caching bugs

XMLWordPrintable

    • x86
    • windows_xp

      J2SE Version:
        6u3 and 6u5 early access builds
      . Same result with new plugin as well.


      Bug Description:

      Two bugs in the 1.6.0 plugin. In 1.6 you have introduced a cache even for downloading from a URL.
       
      First of all, the cache does not seem to compare the last modified time or file size to see if the
      file in the cache is the same as the file available on the web server. If having caching enabled
      (a default URLConnection), download the file from the URL, then modify the file, and then try to
      download it again you will get the file from the cache even though it is not current.
       
      Trying to work around this issue by trying to disable the cache. Using UrlConnection.setUseCaches(false),
      the file you are downloading does not end up in the cache as expected, but if you modify the
      file that
      you are downloading on the web server you will still end up downloading the original
      file for 15 seconds
      (as if it is cached???).
       
      Here is a code snippet:
       
                  URLConnection urlConn = encryptedFileUrl.openConnection();
                  urlConn.setUseCaches(false);
                  urlConn.setRequestProperty("Cache-Control","no-store,max-age=0,no-cache");
                  urlConn.setRequestProperty("Expires","0");
                  urlConn.setRequestProperty("Pragma","no-cache");
                  urlConn.connect();
                  InputStream in = urlConn.getInputStream();
                  ...

            almatvee Alexander Matveev
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: