private static long getExpires(String resource) {
        String query = resource.substring(Math.min(resource.length(), resource.indexOf("?")+1),
                resource.length());
        for (String s : query.split("&")) {
            String[] kv = s.split("=", 2);
            if (kv != null && kv.length == 2) {
                try {
                    String name = URLDecoder.decode(kv[0], "UTF-8");
                    if (EXPIRES.equalsIgnoreCase(name)) {
                        String value = URLDecoder.decode(kv[1], "UTF-8");
                        try {
                            return Long.parseLong(value) * 1000L;
                        } catch (NumberFormatException ignored) {
                        }
                    }
                } catch (UnsupportedEncodingException ignored) {}
            }
        }
        return System.currentTimeMillis() + DEFAULT_URL_LIFETIME;
    }