Cache updates
This commit is contained in:
parent
198f790bed
commit
4238717460
|
@ -7,7 +7,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group = 'com.mangadex'
|
group = 'com.mangadex'
|
||||||
version = '1.0.0-rc1'
|
version = '1.0.0-rc2'
|
||||||
mainClassName = 'mdnet.base.MangadexClient'
|
mainClassName = 'mdnet.base.MangadexClient'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
|
|
@ -48,6 +48,12 @@ public class MangadexClient {
|
||||||
public void runLoop() {
|
public void runLoop() {
|
||||||
statistics.set(new Statistics());
|
statistics.set(new Statistics());
|
||||||
loginAndStartServer();
|
loginAndStartServer();
|
||||||
|
if (serverSettings.getLatestBuild() > Constants.CLIENT_BUILD) {
|
||||||
|
if (LOGGER.isWarnEnabled()) {
|
||||||
|
LOGGER.warn("Outdated build detected! Latest: {}, Current: {}", serverSettings.getLatestBuild(),
|
||||||
|
Constants.CLIENT_BUILD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (LOGGER.isInfoEnabled()) {
|
if (LOGGER.isInfoEnabled()) {
|
||||||
LOGGER.info("MDNet initialization completed successfully. Starting normal operation.");
|
LOGGER.info("MDNet initialization completed successfully. Starting normal operation.");
|
||||||
|
@ -94,11 +100,20 @@ public class MangadexClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerSettings n = serverHandler.pingControl(serverSettings);
|
ServerSettings n = serverHandler.pingControl(serverSettings);
|
||||||
|
|
||||||
if (LOGGER.isInfoEnabled()) {
|
if (LOGGER.isInfoEnabled()) {
|
||||||
LOGGER.info("Server settings received: {}", n);
|
LOGGER.info("Server settings received: {}", n);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n != null && (n.getTls() != null || !n.getImageServer().equals(serverSettings.getImageServer()))) {
|
if (n != null) {
|
||||||
|
if (n.getLatestBuild() > Constants.CLIENT_BUILD) {
|
||||||
|
if (LOGGER.isWarnEnabled()) {
|
||||||
|
LOGGER.warn("Outdated build detected! Latest: {}, Current: {}", n.getLatestBuild(),
|
||||||
|
Constants.CLIENT_BUILD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n.getTls() != null || !n.getImageServer().equals(serverSettings.getImageServer())) {
|
||||||
// certificates or upstream url must have changed, restart webserver
|
// certificates or upstream url must have changed, restart webserver
|
||||||
if (LOGGER.isInfoEnabled()) {
|
if (LOGGER.isInfoEnabled()) {
|
||||||
LOGGER.info("Doing internal restart of HTTP server to refresh certs/upstream URL");
|
LOGGER.info("Doing internal restart of HTTP server to refresh certs/upstream URL");
|
||||||
|
@ -109,6 +124,7 @@ public class MangadexClient {
|
||||||
loginAndStartServer();
|
loginAndStartServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}, 45, 45, TimeUnit.SECONDS);
|
}, 45, 45, TimeUnit.SECONDS);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,13 @@ public final class ServerSettings {
|
||||||
@SerializedName("image_server")
|
@SerializedName("image_server")
|
||||||
private final String imageServer;
|
private final String imageServer;
|
||||||
private final TlsCert tls;
|
private final TlsCert tls;
|
||||||
|
@SerializedName("latest_build")
|
||||||
|
private final int latestBuild;
|
||||||
|
|
||||||
public ServerSettings(String imageServer, TlsCert tls) {
|
public ServerSettings(String imageServer, TlsCert tls, int latestBuild) {
|
||||||
this.imageServer = Objects.requireNonNull(imageServer);
|
this.imageServer = Objects.requireNonNull(imageServer);
|
||||||
this.tls = tls;
|
this.tls = tls;
|
||||||
|
this.latestBuild = latestBuild;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getImageServer() {
|
public String getImageServer() {
|
||||||
|
@ -22,9 +25,14 @@ public final class ServerSettings {
|
||||||
return tls;
|
return tls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getLatestBuild() {
|
||||||
|
return latestBuild;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ServerSettings{" + "imageServer='" + imageServer + '\'' + ", tls=" + "<hidden>" + '}';
|
return "ServerSettings{" + "imageServer='" + imageServer + '\'' + ", tls=" + tls + ", latestBuild="
|
||||||
|
+ latestBuild + '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -149,13 +149,10 @@ private val HTTP_TIME_FORMATTER = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy
|
||||||
private fun addCommonHeaders(): Filter {
|
private fun addCommonHeaders(): Filter {
|
||||||
return Filter { next: HttpHandler ->
|
return Filter { next: HttpHandler ->
|
||||||
{ request: Request ->
|
{ request: Request ->
|
||||||
val now = ZonedDateTime.now(ZoneOffset.UTC)
|
|
||||||
val response = next(request)
|
val response = next(request)
|
||||||
response.header("Date", HTTP_TIME_FORMATTER.format(now))
|
response.header("Date", HTTP_TIME_FORMATTER.format(ZonedDateTime.now(ZoneOffset.UTC)))
|
||||||
.header("Server", "Mangadex@Home Node")
|
.header("Server", "Mangadex@Home Node")
|
||||||
.header("Cache-Control", listOf("public", MaxAgeTtl(Constants.MAX_AGE_CACHE).toHeaderValue()).joinToString(", "))
|
.header("Cache-Control", listOf("public", MaxAgeTtl(Constants.MAX_AGE_CACHE).toHeaderValue()).joinToString(", "))
|
||||||
.header("Expires", HTTP_TIME_FORMATTER.format(now.plusSeconds(Constants.MAX_AGE_CACHE.seconds)))
|
|
||||||
.header("Cache-Control", "public, max-age=604800") // 1 week browser cache
|
|
||||||
.header("Timing-Allow-Origin", "https://mangadex.org")
|
.header("Timing-Allow-Origin", "https://mangadex.org")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue