mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-10-09 05:41:21 +00:00
Don't let browsers cache job directory files for 10 minutes (#782)
Restlet's Directory gives every file an Expires header 10 minutes in the future. Job files (logs, reports, crawler-beans.cxml) change constantly, so browsers could show stale copies. Worst case, the config editor loads a cached crawler-beans.cxml and saving it silently reverts newer changes. Clear the expiration date and send Cache-Control: no-cache instead, so browsers revalidate against Last-Modified on each use.
This commit is contained in:
1 parent
be6b49fa6c
commit
d6747686e3
1 file changed
+9
@@ -29,6 +29,7 @@ import org.restlet.Context;
|
||||
import org.restlet.data.Reference;
|
||||
import org.restlet.Request;
|
||||
import org.restlet.Response;
|
||||
import org.restlet.data.CacheDirective;
|
||||
import org.restlet.data.Status;
|
||||
import org.restlet.resource.Directory;
|
||||
import org.restlet.resource.ServerResource;
|
||||
@@ -72,6 +73,14 @@ public abstract class EnhDirectory extends Directory {
|
||||
if (response.getStatus() == Status.SUCCESS_NO_CONTENT) {
|
||||
response.setStatus(Status.SUCCESS_OK);
|
||||
}
|
||||
|
||||
// Job files (logs, reports, configs) change constantly, so replace Restlet's default
|
||||
// 10 minute expiry with revalidation against Last-Modified. Otherwise the config editor
|
||||
// can load a stale copy and saving it silently reverts newer changes.
|
||||
if (response.getEntity() != null) {
|
||||
response.getEntity().setExpirationDate(null);
|
||||
}
|
||||
response.getCacheDirectives().add(CacheDirective.noCache());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user