Do not do ETag caching when the version is updated

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2017-05-02 08:44:20 +02:00
parent f27d382c47
commit 095463d568
No known key found for this signature in database
GPG Key ID: F941078878347C0C
1 changed files with 12 additions and 12 deletions

View File

@ -125,19 +125,19 @@ abstract class Fetcher {
$file = $rootFolder->getFile($this->fileName);
$jsonBlob = json_decode($file->getContent(), true);
if (is_array($jsonBlob)) {
/*
* If the timestamp is older than 300 seconds request the files new
* If the version changed (update!) also refresh
*/
if ((int)$jsonBlob['timestamp'] > ($this->timeFactory->getTime() - self::INVALIDATE_AFTER_SECONDS) &&
isset($jsonBlob['ncversion']) && $jsonBlob['ncversion'] === $this->config->getSystemValue('version', '0.0.0')
) {
return $jsonBlob['data'];
}
if (isset($jsonBlob['ETag'])) {
$ETag = $jsonBlob['ETag'];
$content = json_encode($jsonBlob['data']);
// No caching when the version has been updated
if (isset($jsonBlob['ncversion']) && $jsonBlob['ncversion'] === $this->config->getSystemValue('version', '0.0.0')) {
// If the timestamp is older than 300 seconds request the files new
if ((int)$jsonBlob['timestamp'] > ($this->timeFactory->getTime() - self::INVALIDATE_AFTER_SECONDS)) {
return $jsonBlob['data'];
}
if (isset($jsonBlob['ETag'])) {
$ETag = $jsonBlob['ETag'];
$content = json_encode($jsonBlob['data']);
}
}
}
} catch (NotFoundException $e) {