From c60aed44352067f708c418ebf83f5a6337dfc6eb Mon Sep 17 00:00:00 2001 From: orbiter Date: Wed, 29 Sep 2010 19:56:42 +0000 Subject: [PATCH] no caching in browser of dynamic web pages sent by YaCy http this may prevent unnecessary IO caused by cache storage of the browser git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7207 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/http/server/HTTPDFileHandler.java | 6 +++++- source/de/anomic/http/server/HTTPDemon.java | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) 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";