private void writeConfigToFile(RawConfig config, String path) {
        String filename = path + File.separator + createCacheFileName(config);
        Writer writer = null;
        try {
            log.log(Level.FINE, () -> "Writing '" + config.getKey() + "' to '" + filename + "'");
            final Payload payload = config.getPayload();
            long protocolVersion = 3;
            log.log(Level.FINE, () -> "Writing config '" + config + "' to file '" + filename + "' with protocol version " + protocolVersion);
            writer = IOUtils.createWriter(filename, "UTF-8", false);

            // First three lines are meta-data about config as comment lines, fourth line is empty
            writer.write("# defMd5:" + config.getDefMd5() + "\n");
            writer.write("# config checksums:" + config.getPayloadChecksums() + "\n");
            writer.write("# generation:" + config.getGeneration() + "\n");
            writer.write("# protocolVersion:" + protocolVersion + "\n");
            writer.write("\n");
            writer.write(payload.withCompression(CompressionType.UNCOMPRESSED).toString());
            writer.write("\n");
            writer.close();
        } catch (IOException e) {
            log.log(Level.WARNING, "Could not write to file '" + filename + "'");
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
Put in cache, except when config has an error

@param config config to update in cache
config-proxy/src/main/java/com/yahoo/vespa/config/proxy/MemoryCache.java