mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-26 02:25:50 +01:00
Garmin: only add the cache-control header when updating the AGPS file
Prevents it being stale for too long if the user forgets to fetch an updated file. If the file has to be updated on the watch the response (http status 200) is sent and cached for 14400 seconds, for this period the watch will not request the file again. Subsequent requests (http status 304) are very small and should not impact battery life negatively, hence they are sent without adding caching directives.
This commit is contained in:
parent
09ca34fedf
commit
fc8b959fea
@ -50,7 +50,6 @@ public class AgpsHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final GarminHttpResponse response = new GarminHttpResponse();
|
final GarminHttpResponse response = new GarminHttpResponse();
|
||||||
response.getHeaders().put("cache-control", "max-age=14400");
|
|
||||||
|
|
||||||
final byte[] rawBytes = FileUtils.readAll(agpsIn, 1024 * 1024); // 1MB, they're usually ~60KB
|
final byte[] rawBytes = FileUtils.readAll(agpsIn, 1024 * 1024); // 1MB, they're usually ~60KB
|
||||||
final String fileHash = GB.hexdump(CheckSums.md5(rawBytes)).toLowerCase(Locale.ROOT);
|
final String fileHash = GB.hexdump(CheckSums.md5(rawBytes)).toLowerCase(Locale.ROOT);
|
||||||
@ -68,6 +67,7 @@ public class AgpsHandler {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
response.getHeaders().put("cache-control", "max-age=14400");
|
||||||
|
|
||||||
// Run some sanity checks on known agps file formats
|
// Run some sanity checks on known agps file formats
|
||||||
final GarminAgpsFile garminAgpsFile = new GarminAgpsFile(rawBytes);
|
final GarminAgpsFile garminAgpsFile = new GarminAgpsFile(rawBytes);
|
||||||
|
Loading…
Reference in New Issue
Block a user