Changeset 9228 in josm for trunk


Ignore:
Timestamp:
2015-12-31T10:37:05+01:00 (8 years ago)
Author:
wiktorn
Message:

Do not use cache when downloading.

This avoids getting objects from Java Web Start Cache, though it will
also skip any tile cache in between, which may result in bigger load of
tile servers.

See #12235

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java

    r9212 r9228  
    311311            }
    312312
    313             HttpURLConnection urlConn = getURLConnection(getUrl());
     313            HttpURLConnection urlConn = getURLConnection(getUrl(), true);
    314314
    315315            if (isObjectLoadable()  &&
     
    326326            for (int i = 0; i < 5; i++) {
    327327                if (urlConn.getResponseCode() == 302) {
    328                     urlConn = getURLConnection(new URL(urlConn.getHeaderField("Location")));
     328                    urlConn = getURLConnection(new URL(urlConn.getHeaderField("Location")), true);
    329329                } else {
    330330                    break;
     
    470470    }
    471471
    472     private HttpURLConnection getURLConnection(URL url) throws IOException {
     472    private HttpURLConnection getURLConnection(URL url, boolean noCache) throws IOException {
    473473        HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
    474474        urlConn.setRequestProperty("Accept", "text/html, image/png, image/jpeg, image/gif, */*");
     
    481481        }
    482482
    483         if (force) {
     483        if (force || noCache) {
    484484            urlConn.setUseCaches(false);
    485485        }
     
    488488
    489489    private boolean isCacheValidUsingHead() throws IOException {
    490         HttpURLConnection urlConn = getURLConnection(getUrl());
     490        HttpURLConnection urlConn = getURLConnection(getUrl(), false);
    491491        urlConn.setRequestMethod("HEAD");
    492492        for (int i = 0; i < 5; i++) {
    493493            if (urlConn.getResponseCode() == 302) {
    494                 urlConn = getURLConnection(new URL(urlConn.getHeaderField("Location")));
     494                urlConn = getURLConnection(new URL(urlConn.getHeaderField("Location")), false);
    495495            } else {
    496496                break;
Note: See TracChangeset for help on using the changeset viewer.