mirror of
https://gitlab.com/mangadex-pub/mangadex_at_home.git
synced 2024-01-19 02:48:37 +00:00
Cache updates
This commit is contained in:
parent
198f790bed
commit
4238717460
|
@ -7,7 +7,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = 'com.mangadex'
|
||||
version = '1.0.0-rc1'
|
||||
version = '1.0.0-rc2'
|
||||
mainClassName = 'mdnet.base.MangadexClient'
|
||||
|
||||
repositories {
|
||||
|
|
|
@ -48,6 +48,12 @@ public class MangadexClient {
|
|||
public void runLoop() {
|
||||
statistics.set(new Statistics());
|
||||
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()) {
|
||||
LOGGER.info("MDNet initialization completed successfully. Starting normal operation.");
|
||||
|
@ -94,11 +100,20 @@ public class MangadexClient {
|
|||
}
|
||||
|
||||
ServerSettings n = serverHandler.pingControl(serverSettings);
|
||||
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
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
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info("Doing internal restart of HTTP server to refresh certs/upstream URL");
|
||||
|
@ -109,6 +124,7 @@ public class MangadexClient {
|
|||
loginAndStartServer();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 45, 45, TimeUnit.SECONDS);
|
||||
|
||||
}
|
||||
|
|
|
@ -8,10 +8,13 @@ public final class ServerSettings {
|
|||
@SerializedName("image_server")
|
||||
private final String imageServer;
|
||||
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.tls = tls;
|
||||
this.latestBuild = latestBuild;
|
||||
}
|
||||
|
||||
public String getImageServer() {
|
||||
|
@ -22,9 +25,14 @@ public final class ServerSettings {
|
|||
return tls;
|
||||
}
|
||||
|
||||
public int getLatestBuild() {
|
||||
return latestBuild;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServerSettings{" + "imageServer='" + imageServer + '\'' + ", tls=" + "<hidden>" + '}';
|
||||
return "ServerSettings{" + "imageServer='" + imageServer + '\'' + ", tls=" + tls + ", latestBuild="
|
||||
+ latestBuild + '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -149,13 +149,10 @@ private val HTTP_TIME_FORMATTER = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy
|
|||
private fun addCommonHeaders(): Filter {
|
||||
return Filter { next: HttpHandler ->
|
||||
{ request: Request ->
|
||||
val now = ZonedDateTime.now(ZoneOffset.UTC)
|
||||
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("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")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue