Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

no caching in browser of dynamic web pages sent by YaCy http this may prevent unnecessary IO caused by cache storage of the browser

orbiterc60aed443520
diff --git a/source/de/anomic/http/server/HTTPDFileHandler.java b/source/de/anomic/http/server/HTTPDFileHandler.java
index 164df05ea..18cdd5850 100644
--- a/source/de/anomic/http/server/HTTPDFileHandler.java
+++ b/source/de/anomic/http/server/HTTPDFileHandler.java
@@ -274,6 +274,9 @@ public final class HTTPDFileHandler {
if (authorization != null && authorization.length() == 0) authorization = null;
final String adminAccountBase64MD5 = switchboard.getConfig(HTTPDemon.ADMIN_ACCOUNT_B64MD5, "");
+ // cache settings
+ boolean nocache = path.contains("?") || body != null;
+
// a bad patch to map the /xml/ path to /api/
if (path.startsWith("/xml/")) {
path = "/api/" + path.substring(5);
@@ -388,6 +391,8 @@ public final class HTTPDFileHandler {
}
}
}
+
+ if (args != null) nocache = true;
// we are finished with parsing
// the result of value hand-over is in args and argc
@@ -504,7 +509,6 @@ public final class HTTPDFileHandler {
//We need tp here
servletProperties templatePatterns = null;
Date targetDate;
- boolean nocache = false;
if ((targetClass != null) && (path.endsWith("png"))) {
// call an image-servlet to produce an on-the-fly - generated image
diff --git a/source/de/anomic/http/server/HTTPDemon.java b/source/de/anomic/http/server/HTTPDemon.java
index d5a17cc49..92168368b 100644
--- a/source/de/anomic/http/server/HTTPDemon.java
+++ b/source/de/anomic/http/server/HTTPDemon.java
@@ -1188,8 +1188,9 @@ public final class HTTPDemon implements serverHandler, Cloneable {
headers.put(HeaderFramework.LAST_MODIFIED, HeaderFramework.formatRFC1123(moddate));
if (nocache) {
- if (httpVersion.toUpperCase().equals(HeaderFramework.HTTP_VERSION_1_1)) headers.put(HeaderFramework.CACHE_CONTROL, "no-cache");
- else headers.put(HeaderFramework.PRAGMA, "no-cache");
+ headers.put(HeaderFramework.CACHE_CONTROL, "no-cache");
+ headers.put(HeaderFramework.CACHE_CONTROL, "no-store");
+ headers.put(HeaderFramework.PRAGMA, "no-cache");
}
if (contentType == null) contentType = "text/html; charset=UTF-8";