Skip to content

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

- fix for 'do not write to cache' rule. - do not read from cache if byte[] array is still filled from response object (will do less IO)

orbiter2bc3cba6f100
diff --git a/source/de/anomic/search/Switchboard.java b/source/de/anomic/search/Switchboard.java
index 84e19b51d..98a18e4e1 100644
--- a/source/de/anomic/search/Switchboard.java
+++ b/source/de/anomic/search/Switchboard.java
@@ -1639,9 +1639,10 @@ public final class Switchboard extends serverSwitch {
// PARSE CONTENT
final long parsingStartTime = System.currentTimeMillis();
- byte[] b = null;
- try {
- // fetch the document
+ // fetch the document from the response
+ byte[] b = response.getContent();
+ if (b == null) try {
+ // fetch the document from cache
b = Cache.getContent(response.url());
if (b == null) {
this.log.logWarning("the resource '" + response.url() + "' is missing in the cache.");
diff --git a/source/net/yacy/repository/LoaderDispatcher.java b/source/net/yacy/repository/LoaderDispatcher.java
index 6679906ed..e33f01fcf 100644
--- a/source/net/yacy/repository/LoaderDispatcher.java
+++ b/source/net/yacy/repository/LoaderDispatcher.java
@@ -264,6 +264,12 @@ public final class LoaderDispatcher {
if (protocol.equals("smb")) response = smbLoader.load(request, true);
if (response != null) {
// we got something. Now check if we want to store that to the cache
+ // first check looks if we want to store the content to the cache
+ if (!crawlProfile.storeHTCache()) {
+ // no caching wanted. Thats ok, do not write any message
+ return response;
+ }
+ // second check tells us if the protocoll tells us something about caching
String storeError = response.shallStoreCacheForCrawler();
if (storeError == null) {
try {