Allow more to be cached at the browser.

This commit is contained in:
FireMasterK 2021-04-22 19:52:32 +05:30
parent 2139b1431b
commit 98ecee55aa
No known key found for this signature in database
GPG key ID: 8DFF5DD33E93DB58

View file

@ -79,7 +79,7 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher {
})).map("/channels/:channelId", AsyncServlet.ofBlocking(executor, request -> { })).map("/channels/:channelId", AsyncServlet.ofBlocking(executor, request -> {
try { try {
return getJsonResponse(ResponseHelper.channelResponse(request.getPathParameter("channelId")), return getJsonResponse(ResponseHelper.channelResponse(request.getPathParameter("channelId")),
"public, s-maxage=600"); "public, max-age=600");
} catch (Exception e) { } catch (Exception e) {
return getErrorResponse(e); return getErrorResponse(e);
} }
@ -88,14 +88,14 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher {
return getJsonResponse( return getJsonResponse(
ResponseHelper.channelPageResponse(request.getPathParameter("channelId"), ResponseHelper.channelPageResponse(request.getPathParameter("channelId"),
request.getQueryParameter("url"), request.getQueryParameter("id")), request.getQueryParameter("url"), request.getQueryParameter("id")),
"public, s-maxage=3600"); "public, max-age=3600");
} catch (Exception e) { } catch (Exception e) {
return getErrorResponse(e); return getErrorResponse(e);
} }
})).map("/playlists/:playlistId", AsyncServlet.ofBlocking(executor, request -> { })).map("/playlists/:playlistId", AsyncServlet.ofBlocking(executor, request -> {
try { try {
return getJsonResponse(ResponseHelper.playlistResponse(request.getPathParameter("playlistId")), return getJsonResponse(ResponseHelper.playlistResponse(request.getPathParameter("playlistId")),
"public, s-maxage=600"); "public, max-age=600");
} catch (Exception e) { } catch (Exception e) {
return getErrorResponse(e); return getErrorResponse(e);
} }
@ -104,21 +104,21 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher {
return getJsonResponse( return getJsonResponse(
ResponseHelper.playlistPageResponse(request.getPathParameter("playlistId"), ResponseHelper.playlistPageResponse(request.getPathParameter("playlistId"),
request.getQueryParameter("url"), request.getQueryParameter("id")), request.getQueryParameter("url"), request.getQueryParameter("id")),
"public, s-maxage=3600"); "public, max-age=3600");
} catch (Exception e) { } catch (Exception e) {
return getErrorResponse(e); return getErrorResponse(e);
} }
})).map("/suggestions", AsyncServlet.ofBlocking(executor, request -> { })).map("/suggestions", AsyncServlet.ofBlocking(executor, request -> {
try { try {
return getJsonResponse(ResponseHelper.suggestionsResponse(request.getQueryParameter("query")), return getJsonResponse(ResponseHelper.suggestionsResponse(request.getQueryParameter("query")),
"public, s-maxage=600"); "public, max-age=600");
} catch (Exception e) { } catch (Exception e) {
return getErrorResponse(e); return getErrorResponse(e);
} }
})).map("/search", AsyncServlet.ofBlocking(executor, request -> { })).map("/search", AsyncServlet.ofBlocking(executor, request -> {
try { try {
return getJsonResponse(ResponseHelper.searchResponse(request.getQueryParameter("q")), return getJsonResponse(ResponseHelper.searchResponse(request.getQueryParameter("q")),
"public, s-maxage=600"); "public, max-age=600");
} catch (Exception e) { } catch (Exception e) {
return getErrorResponse(e); return getErrorResponse(e);
} }
@ -127,27 +127,27 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher {
return getJsonResponse( return getJsonResponse(
ResponseHelper.searchPageResponse(request.getQueryParameter("q"), ResponseHelper.searchPageResponse(request.getQueryParameter("q"),
request.getQueryParameter("url"), request.getQueryParameter("id")), request.getQueryParameter("url"), request.getQueryParameter("id")),
"public, s-maxage=3600"); "public, max-age=3600");
} catch (Exception e) { } catch (Exception e) {
return getErrorResponse(e); return getErrorResponse(e);
} }
})).map("/trending", AsyncServlet.ofBlocking(executor, request -> { })).map("/trending", AsyncServlet.ofBlocking(executor, request -> {
try { try {
return getJsonResponse(ResponseHelper.trendingResponse(), "public, s-maxage=3600"); return getJsonResponse(ResponseHelper.trendingResponse(), "public, max-age=3600");
} catch (Exception e) { } catch (Exception e) {
return getErrorResponse(e); return getErrorResponse(e);
} }
})).map("/comments/:videoId", AsyncServlet.ofBlocking(executor, request -> { })).map("/comments/:videoId", AsyncServlet.ofBlocking(executor, request -> {
try { try {
return getJsonResponse(ResponseHelper.commentsResponse(request.getPathParameter("videoId")), return getJsonResponse(ResponseHelper.commentsResponse(request.getPathParameter("videoId")),
"public, s-maxage=1200"); "public, max-age=1200");
} catch (Exception e) { } catch (Exception e) {
return getErrorResponse(e); return getErrorResponse(e);
} }
})).map("/nextpage/comments/:videoId", AsyncServlet.ofBlocking(executor, request -> { })).map("/nextpage/comments/:videoId", AsyncServlet.ofBlocking(executor, request -> {
try { try {
return getJsonResponse(ResponseHelper.commentsPageResponse(request.getPathParameter("videoId"), return getJsonResponse(ResponseHelper.commentsPageResponse(request.getPathParameter("videoId"),
request.getQueryParameter("url")), "public, s-maxage=3600"); request.getQueryParameter("url")), "public, max-age=3600");
} catch (Exception e) { } catch (Exception e) {
return getErrorResponse(e); return getErrorResponse(e);
} }